-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
47 lines (36 loc) · 1.56 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
44
45
46
47
# Builder Stage
FROM node:iron-alpine AS builder
WORKDIR /app
COPY . .
RUN npm ci
RUN npm run build
# Production Stage
FROM node:iron-alpine AS production
WORKDIR /app
LABEL name="nextjs" \
description="Plamosphere Website" \
eu.mia-platform.url="https://www.mia-platform.eu"
# add env vars here to have them available on printenv or process.env
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
ENV NEXT_SHARP_PATH "/app/node_modules/sharp"
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# copy the public folder from the project as this is not included in the build process
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
# copy the standalone folder inside the .next folder generated from the build process
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
# copy the static folder inside the .next folder generated from the build process
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
# copy the static folder inside the .next folder generated from the build process
COPY --from=builder --chown=nextjs:nodejs /app/entrypoint.sh ./entrypoint.sh
# change permissions on app folder
RUN chown -R nextjs:nodejs /app
USER nextjs
RUN chmod 700 /app
# This script replaces placeholder strings created by Next build at build time (to be used as env vars) with env vars values available at runtime.
# NB: env vars are replaced only if they start with REPLACE_SERVER_ENV_ keyword
RUN chmod +x ./entrypoint.sh
EXPOSE 3000
ENV PORT 3000
ENTRYPOINT ["/app/entrypoint.sh", "node", "server.js"]