Jotzy/frontend/Dockerfile

32 lines
742 B
Docker
Raw Normal View History

2026-01-06 13:10:06 +00:00
# ---------- Builder ----------
2026-01-06 12:51:40 +00:00
FROM node:20-alpine AS builder
WORKDIR /app
2026-01-06 13:28:32 +00:00
# Accept build argument
ARG VITE_API_URL
ENV VITE_API_URL=$VITE_API_URL
2026-01-06 16:41:39 +00:00
# Copy package files and install dependencies
2026-01-06 12:51:40 +00:00
COPY package*.json ./
2026-01-06 16:41:39 +00:00
RUN npm ci --prefer-offline --no-audit
# Copy source and build
2026-01-06 12:51:40 +00:00
COPY . .
2026-01-06 13:28:32 +00:00
RUN npm run build
2026-01-06 13:10:06 +00:00
# ---------- Runtime ----------
FROM nginx:stable-alpine AS runtime
2026-01-06 16:41:39 +00:00
# Copy custom nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy built assets
2026-01-06 12:51:40 +00:00
COPY --from=builder /app/dist /usr/share/nginx/html
2026-01-06 16:41:39 +00:00
# Add healthcheck
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost/health || exit 1
2026-01-06 12:51:40 +00:00
EXPOSE 80
2026-01-06 13:10:06 +00:00
CMD ["nginx", "-g", "daemon off;"]