-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.web
More file actions
50 lines (35 loc) · 1.03 KB
/
Dockerfile.web
File metadata and controls
50 lines (35 loc) · 1.03 KB
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
49
50
# Build stage
FROM node:18-alpine AS builder
# Install pnpm
RUN corepack enable && corepack prepare pnpm@10.10.0 --activate
# Set working directory
WORKDIR /app
# Copy package files for better caching
COPY web/package.json web/pnpm-lock.yaml ./
# Install dependencies
RUN pnpm install --frozen-lockfile --prefer-offline
# Copy source code
COPY web/ ./
# Accept build arguments
ARG REACT_APP_API_URL
# Build the application
RUN pnpm run build
# Production stage
FROM node:18-alpine
# Install pnpm and serve globally
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable && corepack prepare pnpm@10.10.0 --activate && mkdir -p $PNPM_HOME && pnpm add -g serve
# Create a non-root user
RUN addgroup -g 1001 -S nodejs
RUN adduser -S appuser -u 1001
# Set working directory
WORKDIR /app
# Copy built application from builder stage
COPY --from=builder --chown=appuser:nodejs /app/build ./build
# Switch to non-root user
USER appuser
# Expose port 5000
EXPOSE 5000
# Start the application
CMD ["serve", "-s", "build", "-l", "5000"]