40 lines
1.2 KiB
Docker
40 lines
1.2 KiB
Docker
# syntax=docker/dockerfile:1
|
|
|
|
# ---------- Stage 1: build the static site ----------
|
|
FROM node:22-alpine AS build
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy manifests first so Docker can cache the dependency install layer
|
|
COPY package.json package-lock.json ./
|
|
COPY apps/web/package.json apps/web/package.json
|
|
|
|
RUN npm ci --no-audit --no-fund
|
|
|
|
# Copy the rest of the source and build
|
|
COPY . .
|
|
|
|
RUN npm run build --workspace apps/web
|
|
|
|
# Fail the build loudly if the static output is not where we expect it,
|
|
# instead of shipping an empty web root that 404s at runtime.
|
|
RUN test -f /app/dist/apps/web/index.html
|
|
|
|
# ---------- Stage 2: serve with Nginx ----------
|
|
FROM nginx:1.27-alpine
|
|
|
|
# Remove the default nginx config (the one that shows "Welcome to nginx!")
|
|
RUN rm -f /etc/nginx/conf.d/default.conf
|
|
|
|
COPY nginx.conf /etc/nginx/conf.d/mazzei.conf
|
|
COPY --from=build /app/dist/apps/web /usr/share/nginx/html
|
|
|
|
# 80 is the primary port; 3000 is also listened on so deployments that
|
|
# expect the common default (e.g. Coolify's port setting) work unchanged.
|
|
EXPOSE 80 3000
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD wget -qO- http://127.0.0.1/ >/dev/null 2>&1 || exit 1
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|