-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile
43 lines (29 loc) · 879 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
40
41
42
43
# syntax = docker/dockerfile:1
# Adjust NODE_VERSION as desired
FROM node:22.9.0-alpine AS base
# Next.js app lives here
WORKDIR /app
# Set production environment
ENV NODE_ENV="production"
ARG YARN_VERSION=1.22.21
RUN npm install -g yarn@$YARN_VERSION --force
# Install packages needed to build node modules
FROM base AS build
# Install node modules
COPY --link package.json yarn.lock ./
RUN yarn install --frozen-lockfile --production=false --network-timeout 1000000
# Copy application code
COPY --link . .
# Build application
RUN yarn run build
# Final stage for app image
FROM base
ENV NODE_ENV="production"
ENV NEXT_TELEMETRY_DISABLED=1
# Copy built application from the previous stage
COPY --from=build /app /app
RUN adduser -S -u 1001 nextjs
# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
USER nextjs
CMD [ "node", "server.js" ]