chore(deploy): add Dockerfile and nginx config for Coolify SPA hosting
Multi-stage build: node:22-alpine + pnpm builds, nginx:1.27-alpine serves. VITE_* env vars are passed as build args because Vite inlines them into the JS bundle at build time. nginx config does SPA fallback, caches /assets/* immutably, and forces no-store on sw.js/index.html so PWA updates propagate.
This commit is contained in:
34
Dockerfile
Normal file
34
Dockerfile
Normal file
@@ -0,0 +1,34 @@
|
||||
# syntax=docker/dockerfile:1.7
|
||||
|
||||
# -------- Build stage --------
|
||||
FROM node:22-alpine AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# pnpm via corepack — pin the version that matches package.json
|
||||
RUN corepack enable && corepack prepare pnpm@11.5.0 --activate
|
||||
|
||||
# Install deps first (cached as long as the lockfile is unchanged)
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Build-time env (Vite inlines VITE_* into the bundle)
|
||||
ARG VITE_COUCHDB
|
||||
ARG VITE_MAPBOX_KEY
|
||||
ARG VITE_MAP_KEY
|
||||
ENV VITE_COUCHDB=$VITE_COUCHDB \
|
||||
VITE_MAPBOX_KEY=$VITE_MAPBOX_KEY \
|
||||
VITE_MAP_KEY=$VITE_MAP_KEY
|
||||
|
||||
COPY . .
|
||||
RUN pnpm build
|
||||
|
||||
# -------- Runtime stage --------
|
||||
FROM nginx:1.27-alpine
|
||||
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \
|
||||
CMD wget -qO- http://127.0.0.1/ >/dev/null || exit 1
|
||||
Reference in New Issue
Block a user