-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.node
52 lines (44 loc) · 1.35 KB
/
Dockerfile.node
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
# docker build --build-arg ENVIRONMENT=<environment> -t tracker-node -f Dockerfile.node .
# docker run -p 3000:3000 tracker-node
# Base stage
FROM --platform=linux/amd64 node:20 AS base
# Deps stage
FROM base AS deps
WORKDIR /app
ARG ENVIRONMENT
ENV ENVIRONMENT ${ENVIRONMENT}
COPY ./package*.json ./
RUN node --version
RUN npm install -g n
RUN n 20.10.0
RUN node --version
RUN npm ci
# Build stage
FROM base AS builder
WORKDIR /app
ARG ENVIRONMENT
ENV ENVIRONMENT ${ENVIRONMENT}
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build:${ENVIRONMENT}
# Run stage
FROM base AS runner
RUN npm install -g pm2
WORKDIR /app
ENV NODE_ENV production
ENV APP_ENV aws-dev
COPY --from=builder /app/next.config.mjs ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/scripts ./scripts
COPY --from=builder /app/migrations ./migrations
COPY --from=builder /app/app/utils/pg-app-connect-config.ts ./app/utils/pg-app-connect-config.ts
COPY --from=builder /app/app/utils/pg-migrate-connect-config.ts ./app/utils/pg-migrate-connect-config.ts
RUN pwd
RUN chmod +x ./scripts/entrypoint.sh
EXPOSE 3000
ENV PORT 3000
#CMD ["pm2-runtime", "start", "npm", "--", "start"]
ENTRYPOINT ["./scripts/entrypoint.sh"]