forked from electh/ReactFlux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
37 lines (26 loc) · 884 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
# Stage 1: Build the React application
# Specify the version to ensure consistent builds
FROM node:22-alpine AS build
# Install git and pnpm
RUN apk add --no-cache git && \
npm install -g pnpm
# 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
# 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-alpine
# 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"]