Repository navigation
Expand file tree
/
Copy pathDockerfile.frontend
More file actions
79 lines (65 loc) · 2.84 KB
/
Copy pathDockerfile.frontend
File metadata and controls
79 lines (65 loc) · 2.84 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# ============================================
# Jet Admin - Frontend Container (Multi-Stage)
# ============================================
# Stage 1: Build
FROM node:20-slim AS builder
WORKDIR /app
# Copy dependency definitions
COPY package*.json ./
COPY apps/frontend/package*.json ./apps/frontend/
COPY apps/backend/package*.json ./apps/backend/
# Copy all workspace packages
COPY packages/ ./packages/
COPY scripts/build-packages.js ./scripts/build-packages.js
# Install dependencies (legacy peer deps, same as every other image)
RUN npm install --legacy-peer-deps
# Build workspace packages first: the frontend bundle resolves
# @jet-admin/* entry points to dist/, which is excluded from the build
# context via .dockerignore and never committed to git.
RUN npm run build:packages
# Copy source code (respects .dockerignore)
COPY apps/frontend ./apps/frontend
# Build-time config (Vite bakes import.meta.env.* into the bundle).
# Pass via compose `build.args` or `docker build --build-arg`.
# SERVER/SOCKET hosts can ALSO be overridden at runtime via the
# SERVER_HOST / SOCKET_HOST container env vars (see
# docker-entrypoint.frontend.sh -> /config.js), which take precedence.
ARG VITE_SERVER_HOST=http://localhost:8090
ARG VITE_SOCKET_HOST=http://localhost:8090
ARG VITE_FIREBASE_API_KEY=""
ARG VITE_FIREBASE_AUTH_DOMAIN=""
ARG VITE_FIREBASE_PROJECT_ID=""
ARG VITE_FIREBASE_STORAGE_BUCKET=""
ARG VITE_FIREBASE_MESSAGING_SENDER_ID=""
ARG VITE_FIREBASE_APP_ID=""
ARG VITE_FIREBASE_MEASUREMENT_ID=""
ARG VITE_WEBHOOK_PORT=8095
ENV VITE_SERVER_HOST=$VITE_SERVER_HOST \
VITE_SOCKET_HOST=$VITE_SOCKET_HOST \
VITE_FIREBASE_API_KEY=$VITE_FIREBASE_API_KEY \
VITE_FIREBASE_AUTH_DOMAIN=$VITE_FIREBASE_AUTH_DOMAIN \
VITE_FIREBASE_PROJECT_ID=$VITE_FIREBASE_PROJECT_ID \
VITE_FIREBASE_STORAGE_BUCKET=$VITE_FIREBASE_STORAGE_BUCKET \
VITE_FIREBASE_MESSAGING_SENDER_ID=$VITE_FIREBASE_MESSAGING_SENDER_ID \
VITE_FIREBASE_APP_ID=$VITE_FIREBASE_APP_ID \
VITE_FIREBASE_MEASUREMENT_ID=$VITE_FIREBASE_MEASUREMENT_ID \
VITE_WEBHOOK_PORT=$VITE_WEBHOOK_PORT
# Build frontend
WORKDIR /app/apps/frontend
RUN npm run build
# Stage 2: Serve
FROM nginx:alpine
# Copy custom nginx config
COPY nginx.frontend.conf /etc/nginx/nginx.conf
# Copy build artifacts from builder stage
COPY --from=builder /app/apps/frontend/dist /usr/share/nginx/html
# Expose port
EXPOSE 80
# Health check (127.0.0.1: busybox wget resolves `localhost` to ::1 first while
# nginx listens on IPv4 — `localhost` here would flap to unhealthy)
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1/health || exit 1
# Copy entrypoint script for runtime config
COPY docker-entrypoint.frontend.sh /
RUN sed -i 's/\r$//' /docker-entrypoint.frontend.sh && chmod +x /docker-entrypoint.frontend.sh
CMD ["/docker-entrypoint.frontend.sh"]