-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile.frontend
More file actions
34 lines (24 loc) · 961 Bytes
/
Copy pathDockerfile.frontend
File metadata and controls
34 lines (24 loc) · 961 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
# syntax=docker/dockerfile:1
# Stage 1: Build React app
FROM node:20-alpine AS builder
WORKDIR /app
# Build arg — baked into the React bundle at build time
ARG REACT_APP_BACKEND_URL=http://localhost:9442
ENV REACT_APP_BACKEND_URL=$REACT_APP_BACKEND_URL
# Install deps before copying source (layer cache optimization)
# If package.json/yarn.lock unchanged, this layer is reused
COPY frontend/package.json frontend/yarn.lock ./
RUN yarn install --frozen-lockfile --network-timeout 120000
# Copy source and build
COPY frontend/ .
RUN yarn build
# Stage 2: Serve with nginx (minimal image)
FROM nginx:alpine
# Copy built assets
COPY --from=builder /app/build /usr/share/nginx/html
# Copy nginx config
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 3000
HEALTHCHECK --interval=10s --timeout=5s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/ || exit 1
CMD ["nginx", "-g", "daemon off;"]