-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
31 lines (25 loc) · 996 Bytes
/
Dockerfile
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
# --------------------- Build stage ---------------------
FROM node:20.18.0-alpine3.20 AS builder
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN apk add libc6-compat && \
npm install -g pnpm && pnpm install --frozen-lockfile;
COPY . .
RUN pnpm build
# --------------------- Production stage --------------------- 20-alpine3.17
FROM node:20.18.0-alpine3.20 AS production
WORKDIR /app
RUN apk add libc6-compat && \
addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nestjs
ARG APP_PORT
COPY --from=builder --chown=nestjs:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=nestjs:nodejs /app/dist ./dist
COPY --from=builder --chown=nestjs:nodejs /app/public ./public
# Create and set permissions for auth_info directory
RUN mkdir /app/auth_info \
&& chown nestjs:nodejs /app/auth_info \
&& chmod 775 /app/auth_info
USER nestjs
EXPOSE $APP_PORT
CMD [ "node", "dist/main.js" ]