fix: fix bug docker

This commit is contained in:
2026-09-02 20:29:41 +03:30
parent c5bfa5544c
commit aeefe075dd
9 changed files with 118 additions and 65 deletions

View File

@@ -1,36 +1,31 @@
# syntax=docker/dockerfile:1
# syntax=docker/dockerfile:1.7
# ---------- Build stage ----------
FROM node:20-alpine AS build
FROM node:22-alpine AS build
WORKDIR /app
# Install dependencies (cached unless package files change)
COPY package.json package-lock.json ./
RUN npm ci
RUN --mount=type=cache,target=/root/.npm \
npm ci --no-audit --no-fund
# Build the app
COPY . .
# API base URL is baked in at build time (Vite inlines VITE_* vars).
# Override with: docker build --build-arg VITE_API_URL=https://api.example.com/api/v1 .
ARG VITE_API_URL
ENV VITE_API_URL=$VITE_API_URL
# Vite embeds VITE_* variables in the static bundle during this stage.
ARG VITE_API_URL=https://api.persain-game.com/api/v1
ENV VITE_API_URL=${VITE_API_URL}
RUN npm run build
# ---------- Runtime stage ----------
FROM nginx:alpine AS runtime
FROM nginxinc/nginx-unprivileged:1.28-alpine AS runtime
# SPA-aware nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --chown=nginx:nginx nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build --chown=nginx:nginx /app/dist /usr/share/nginx/html
# Static build output
COPY --from=build /app/dist /usr/share/nginx/html
USER nginx
EXPOSE 80
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -q -O /dev/null http://127.0.0.1/ || exit 1
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD wget -q -O /dev/null http://127.0.0.1:8080/healthz || exit 1
CMD ["nginx", "-g", "daemon off;"]