forked from gaiin-platform/amplify-genai-frontend
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
43 lines (34 loc) · 1.46 KB
/
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
37
38
39
40
41
42
43
# ---- Base Node ----
FROM --platform=linux/amd64 node:19-alpine AS base
WORKDIR /app
COPY package*.json ./
# Create a new user "appuser" and give ownership of the "/app" directory
RUN addgroup -S appgroup && adduser -S appuser -G appgroup && \
chown -R appuser:appgroup /app
# ---- Dependencies ----
FROM base AS dependencies
USER appuser
RUN npm ci
# ---- Build ----
FROM dependencies AS build
COPY --chown=appuser:appgroup . .
RUN npm run build
# ---- Production ----
FROM --platform=linux/amd64 node:19-alpine AS production
# Recreate the "appuser" and "appgroup" in the production stage
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
WORKDIR /app
# Copy node_modules from the "dependencies" stage
COPY --from=dependencies /app/node_modules ./node_modules
# Copy build output from the "build" stage
COPY --chown=appuser:appgroup --from=build /app/.next ./.next
COPY --chown=appuser:appgroup --from=build /app/public ./public
COPY --chown=appuser:appgroup --from=build /app/package*.json ./
COPY --chown=appuser:appgroup --from=build /app/next.config.js ./next.config.js
COPY --chown=appuser:appgroup --from=build /app/next-i18next.config.js ./next-i18next.config.js
# Use the new "appuser"
USER appuser
# Expose the port the app will run on
EXPOSE 3000
# Start the application
CMD ["npm", "start"]