-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
36 lines (28 loc) · 940 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
32
33
34
35
36
ARG BASE_IMAGE=node:18.15.0-alpine
# Step 1 - Compile code
FROM ${BASE_IMAGE} as build
WORKDIR /app
COPY --chown=node:node . /app
RUN npm install && npm run generate:api && npm run build --cache /app/.npm/cache
# Remove the cache folder from .next/
RUN rm -rf .next/cache
# Remove node_modules
RUN rm -rf node_modules
# Install only production dep
RUN npm install --production --ignore-scripts && npm cache clean --force
# Step 2 - Prepare production image
FROM ${BASE_IMAGE}
RUN mkdir -p /app
RUN chown -Rh node:node /app
USER node
WORKDIR /app
COPY --chown=node:node --from=build /app/node_modules /app/node_modules
COPY --chown=node:node --from=build /app/dist /app/dist
COPY --chown=node:node --from=build /app/.next /app/.next
COPY --chown=node:node --from=build /app/next.config.js /app/next.config.js
ENV NODE_ENV=production
ENV LOG_LEVEL=info
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
EXPOSE 3000
CMD ["node", "/app/dist/main.js"]