-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (34 loc) · 1003 Bytes
/
Dockerfile
File metadata and controls
44 lines (34 loc) · 1003 Bytes
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
# Stage 1: Build the application
FROM node:22-alpine AS builder
ARG VERSION
ARG GIT_HASH
LABEL stage="builder"
LABEL version=$VERSION
LABEL git_hash=$GIT_HASH
WORKDIR /app
# Copy package files and install dependencies
COPY package.json ./
RUN npm install -g pnpm && pnpm i
# Copy the rest of the application source code
COPY . .
# Build the application for production
RUN pnpm run build
# Stage 2: Production image
FROM node:22-alpine AS production
ARG VERSION
ARG GIT_HASH
LABEL stage="production"
LABEL version=$VERSION
LABEL git_hash=$GIT_HASH
WORKDIR /app
# Copy production dependencies from the builder stage
COPY --from=builder /app/node_modules ./node_modules
# Copy the built application from the builder stage
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/public ./public
# Create credentials directory
RUN mkdir -p /app/.cred
# Expose the application port
EXPOSE 3000
# Start the application
CMD [ "node", "dist/main.js" ]