-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (27 loc) · 933 Bytes
/
Copy pathDockerfile
File metadata and controls
39 lines (27 loc) · 933 Bytes
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
# Stage 1: Build the React application
# Specify the version to ensure consistent builds
FROM --platform=$BUILDPLATFORM node:22-alpine AS build
# Install git
RUN apk add --no-cache git
# enable corepack to use pnpm
RUN corepack enable
# Set the working directory in the container
WORKDIR /app
# Copy the package.json and pnpm-lock.yaml files
COPY package.json pnpm-lock.yaml ./
# Install dependencies using pnpm
RUN pnpm install --frozen-lockfile --ignore-scripts
# Copy the rest of the code
COPY . .
# Build the project
RUN pnpm run build
# Stage 2: Run the server using Caddy
# Specify the version for consistency
FROM caddy:2
# Copy built assets from the builder stage
COPY --from=build /app/build /srv
# Caddy will pick up the Caddyfile automatically
COPY Caddyfile /etc/caddy/Caddyfile
# Expose the port Caddy listens on
EXPOSE 2000
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]