-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.client
More file actions
59 lines (47 loc) · 1.85 KB
/
Dockerfile.client
File metadata and controls
59 lines (47 loc) · 1.85 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
51
52
53
54
55
56
57
58
59
# Client Dockerfile - Static files served by nginx
# This is a lightweight image for serving static assets
FROM node:20-alpine3.20 AS builder
RUN apk add --no-cache git
WORKDIR /app
# Build shared + client workspaces
COPY package.json package-lock.json ./
COPY shared/package.json ./shared/
COPY client/package.json ./client/
RUN npm install --workspaces --include-workspace-root
COPY shared ./shared
RUN npm run build --workspace=shared
# Build client
COPY client/package.json ./client/
COPY shared/package.json ./shared/
# shared/dist is already built in this stage, no need to copy from another stage
RUN npm ci --workspace=client --workspace=shared
COPY client ./client
COPY shared ./shared
# Build client - server URL will be injected at runtime via entrypoint script
# Build-time default is fine since we override at runtime
ARG COMMIT_HASH
ARG VITE_BRANCH
RUN COMMIT_HASH=${COMMIT_HASH} VITE_BRANCH=${VITE_BRANCH} npm run build --workspace=client
# Production: nginx to serve static files
FROM nginx:alpine3.20
# Install sed for runtime HTML injection
RUN apk add --no-cache sed
# Create non-root user for nginx
RUN addgroup -g 1001 -S nginx-app && \
adduser -S nginx-app -u 1001 && \
chown -R nginx-app:nginx-app /var/cache/nginx && \
chown -R nginx-app:nginx-app /var/log/nginx && \
chown -R nginx-app:nginx-app /etc/nginx/conf.d && \
touch /var/run/nginx.pid && \
chown -R nginx-app:nginx-app /var/run/nginx.pid
COPY --from=builder /app/client/dist /usr/share/nginx/html
RUN chown -R nginx-app:nginx-app /usr/share/nginx/html
# Copy nginx configuration and entrypoint script
COPY docker/nginx-client.conf /etc/nginx/conf.d/default.conf
COPY docker/client-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Switch to non-root user
USER nginx-app
EXPOSE 8080
# Use entrypoint to inject server URL at runtime
ENTRYPOINT ["/entrypoint.sh"]