Cybersecurity-Projects/PROJECTS/intermediate/binary-analysis-tool/infra/docker/vite.prod

60 lines
1.9 KiB
Plaintext

# =============================================================================
# AngelaMos | 2026
# vite.prod
# =============================================================================
# Production Dockerfile: builds Vite app, serves via Nginx
# =============================================================================
# syntax=docker/dockerfile:1
# ============================================================================
# BUILD STAGE
# ============================================================================
FROM node:22-slim AS builder
RUN corepack enable && corepack prepare pnpm@10.29.1 --activate
WORKDIR /app
COPY frontend/package.json frontend/pnpm-lock.yaml* frontend/.npmrc* ./
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile
COPY frontend/ .
ARG VITE_API_URL=/api
ARG VITE_APP_TITLE="My App"
ENV VITE_API_URL=${VITE_API_URL} \
VITE_APP_TITLE=${VITE_APP_TITLE}
RUN pnpm build
# ============================================================================
# PRODUCTION STAGE
# ============================================================================
FROM nginx:1.29-alpine AS production
RUN rm -rf /usr/share/nginx/html/* && \
rm /etc/nginx/conf.d/default.conf
COPY --from=builder /app/dist /usr/share/nginx/html
COPY --chown=nginx:nginx infra/nginx/nginx.prod.conf /etc/nginx/nginx.conf
COPY --chown=nginx:nginx infra/nginx/prod.nginx /etc/nginx/conf.d/default.conf
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 -R nginx:nginx /var/run/nginx.pid
USER nginx
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:80/health || exit 1
CMD ["nginx", "-g", "daemon off;"]