-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathDockerfile.web
More file actions
52 lines (38 loc) · 1.29 KB
/
Copy pathDockerfile.web
File metadata and controls
52 lines (38 loc) · 1.29 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
# Z-Image Web - Docker Configuration
#
# Builds the frontend and serves it with nginx
#
# Build: docker build -f Dockerfile.web -t z-image-web .
# Run: docker run -p 3000:80 z-image-web
# === Build Stage ===
FROM node:20-alpine AS builder
# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
WORKDIR /app
# Copy workspace configuration
COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
COPY apps/web/package.json ./apps/web/
COPY packages/shared/package.json ./packages/shared/
# Install dependencies
RUN pnpm install --frozen-lockfile
# Copy source code
COPY packages/shared ./packages/shared
COPY apps/web ./apps/web
# Build arguments for environment variables
ARG VITE_API_URL=""
ENV VITE_API_URL=$VITE_API_URL
# Build shared package first, then web
RUN pnpm --filter @z-image/shared build
RUN pnpm --filter @z-image/web build
# === Production Stage ===
FROM nginx:alpine AS runner
# Copy custom nginx config
COPY apps/web/nginx.conf /etc/nginx/conf.d/default.conf
# Copy built static files
COPY --from=builder /app/apps/web/dist /usr/share/nginx/html
# Expose port
EXPOSE 80
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:80/ || exit 1
CMD ["nginx", "-g", "daemon off;"]