-
Notifications
You must be signed in to change notification settings - Fork 267
/
Dockerfile
48 lines (35 loc) · 1.24 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
48
# ---- Build Stage ----
FROM node:18-bookworm-slim AS build
# Install ca-certificates. Issue: #89
RUN apt-get update
RUN apt-get install -y ca-certificates
# Install Python, g++, and make for building native dependencies
# Issue: https://github.com/docker/getting-started/issues/124
RUN apt-get install -y python3 g++ make && \
apt-get clean
# Set the working directory
WORKDIR /usr/src/app
# Copy the application's package.json and pnpm-lock.yaml to the container
COPY package.json pnpm-lock.yaml ./
# Install pnpm and application dependencies
RUN npm install -g pnpm && \
pnpm install
# Copy the rest of the application to the container
COPY . .
# Build the application for production
RUN pnpm build
# ---- Production Stage ----
FROM node:18-bookworm-slim AS runtime
# Use a non-root user
USER node
# Set the working directory
WORKDIR /usr/src/app
# Copy the build artifacts from the build stage
COPY --from=build /usr/src/app/.next ./.next
COPY --from=build /usr/src/app/public ./public
COPY --from=build /usr/src/app/package.json ./package.json
COPY --from=build /usr/src/app/node_modules ./node_modules
# Expose port 3000 to be accessed outside the container
EXPOSE 3000
# Start the application in production mode
CMD ["npx", "pnpm", "start"]