-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
31 lines (24 loc) · 937 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
FROM node:lts-alpine as dependencies
WORKDIR /my-project
COPY package.json package-lock.json ./
RUN npm ci
FROM node:lts-alpine as builder
WORKDIR /my-project
COPY . .
COPY --from=dependencies /my-project/node_modules ./node_modules
RUN npm run build
FROM node:lts-alpine as runner
WORKDIR /my-project
ENV NODE_ENV production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=builder --chown=nextjs:nodejs /my-project/next.config.js ./
COPY --from=builder --chown=nextjs:nodejs /my-project/public ./public
COPY --from=builder --chown=nextjs:nodejs /my-project/package.json ./package.json
COPY --from=builder --chown=nextjs:nodejs /my-project/.next ./.next
COPY --from=builder --chown=nextjs:nodejs /my-project/node_modules ./node_modules
USER nextjs
EXPOSE 3000
ENV PORT 3000
CMD ["npm", "run", "start"]