-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathDockerfile
39 lines (31 loc) · 971 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
37
38
39
# ---- Base Node ----
FROM node:20-alpine AS base
WORKDIR /app
COPY package*.json ./
# ---- Dependencies ----
FROM base AS dependencies
RUN npm ci
# ---- Build ----
FROM dependencies AS build
COPY . .
RUN npm run build
# ---- Production ----
FROM node:20-alpine AS production
ARG UID=${UID:-1001}
# Add non-root user app, with home directory /app and uid
RUN adduser -D -u ${UID} app \
&& mkdir -p /app \
&& chown -R app /app
WORKDIR /app
COPY --chown=app:app --from=dependencies /app/node_modules ./node_modules
COPY --chown=app:app --from=build /app/.next ./.next
COPY --chown=app:app --from=build /app/public ./public
COPY --chown=app:app --from=build /app/package*.json ./
COPY --chown=app:app --from=build /app/next.config.js ./next.config.js
# COPY --chown=app:app --from=build /app/next-i18next.config.js ./next-i18next.config.js
# Drop privileges
USER app
# Expose the port the app will run on
EXPOSE 8080
# Start the application
CMD ["npm", "start"]