-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (41 loc) · 1.18 KB
/
Dockerfile
File metadata and controls
55 lines (41 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Stage 1: Build the NestJS application
FROM node:22-alpine AS builder
WORKDIR /app
# Install build dependencies using apk
RUN apk add --no-cache \
python3 \
py3-setuptools \
make \
g++ \
build-base
# Copy package.json and package-lock.json for efficient layer caching
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Build the application
RUN npm run build
# Stage 2: Production image
FROM node:22-alpine AS production
WORKDIR /app
# Copy the compiled application from the build stage
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/migrations ./migrations
# Copy package.json and install only production dependencies
COPY package*.json ./
RUN apk add --no-cache \
python3 \
py3-setuptools \
make \
g++ \
build-base && \
npm install --omit=dev && \
apk del python3 py3-setuptools make g++ build-base
# Set environment variables for SQLite path and app port
ENV DB_NAME="bitshala"
ENV APP_PORT="80"
VOLUME /app/data
EXPOSE $APP_PORT
# Set up entrypoint to handle database migration and config generation
ENTRYPOINT ["sh", "-c", "npm run migration:run && node dist/main.js"]