forked from stellar-kracken/swipely_frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (49 loc) · 2.31 KB
/
Copy pathDockerfile
File metadata and controls
61 lines (49 loc) · 2.31 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
# =============================================================================
# Bridge Watch — Frontend Dockerfile
# =============================================================================
# Stages:
# base shared dependencies
# dev Vite dev server with HMR (docker-compose.dev.yml)
# builder Vite production build
# production Nginx serving static files (docker-compose.yml)
FROM node:20-alpine AS base
WORKDIR /app
# Install dependencies first (layer cache friendly). This layer is only
# invalidated when package.json changes, not on every source edit. The
# BuildKit cache mount keeps npm's package cache across builds so even an
# invalidated install re-downloads as little as possible.
COPY package.json ./
RUN --mount=type=cache,sharing=locked,target=/root/.npm npm install
# -----------------------------------------------------------------------------
# Development — Vite dev server with hot module replacement
# -----------------------------------------------------------------------------
FROM base AS dev
# Source is mounted as a volume at runtime, no COPY needed
EXPOSE 5173
# --host 0.0.0.0 required so Vite is reachable from outside the container
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
# -----------------------------------------------------------------------------
# Builder — Vite production build
# -----------------------------------------------------------------------------
FROM base AS builder
COPY . .
RUN npm run build
# -----------------------------------------------------------------------------
# Production — Nginx serving pre-built static assets
# -----------------------------------------------------------------------------
FROM nginx:1.27-alpine AS production
# Copy built assets
COPY --from=builder /app/dist /usr/share/nginx/html
# Custom nginx config: SPA routing + API/WS proxy to backend container
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Non-root user
RUN chown -R nginx:nginx /usr/share/nginx/html && \
chown -R nginx:nginx /var/cache/nginx && \
chown -R nginx:nginx /var/log/nginx && \
touch /var/run/nginx.pid && \
chown nginx:nginx /var/run/nginx.pid
USER nginx
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
CMD wget -qO- http://localhost:80 || exit 1
CMD ["nginx", "-g", "daemon off;"]