Avoid the node:22-alpine crash that fails installs with Exit handler never called. Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
1000 B
Docker
32 lines
1000 B
Docker
# node:22-alpine npm often dies with "Exit handler never called" in Docker builds.
|
|
FROM docker.arvancloud.ir/node:20-alpine AS build
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci --no-audit --no-fund
|
|
|
|
COPY . .
|
|
|
|
# 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
|
|
|
|
FROM docker.arvancloud.ir/nginxinc/nginx-unprivileged:1.28-alpine AS runtime
|
|
|
|
COPY --chown=nginx:nginx nginx.conf /etc/nginx/conf.d/default.conf
|
|
COPY --from=build --chown=nginx:nginx /app/dist /usr/share/nginx/html
|
|
COPY --from=build --chown=nginx:nginx /app/robots.txt /usr/share/nginx/html/robots.txt
|
|
COPY --from=build --chown=nginx:nginx /app/sitemap.xml /usr/share/nginx/html/sitemap.xml
|
|
|
|
USER nginx
|
|
|
|
EXPOSE 8080
|
|
|
|
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;"]
|