51 lines
1.4 KiB
Docker
51 lines
1.4 KiB
Docker
# syntax=docker/dockerfile:1
|
|
|
|
FROM node:22-alpine AS base
|
|
|
|
# Use Alpine mirror
|
|
# RUN sed -i 's|https://dl-cdn.alpinelinux.org/alpine|https://mirror.de.velop.ir/alpine|g' /etc/apk/repositories
|
|
|
|
# Configure npm registry mirror (Liara)
|
|
# ENV NPM_CONFIG_REGISTRY=https://package-mirror.liara.ir/repository/npm/
|
|
# RUN npm config set registry https://package-mirror.liara.ir/repository/npm/
|
|
|
|
# ENV TZ=Asia/Tehran
|
|
|
|
FROM base AS deps
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json ./
|
|
RUN --mount=type=cache,target=/root/.npm \
|
|
npm ci --ignore-scripts --no-fund --no-audit
|
|
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
ARG VITE_API_BASE_URL
|
|
ARG VITE_TOKEN_NAME
|
|
ARG VITE_REFRESH_TOKEN_NAME
|
|
ENV VITE_API_BASE_URL=$VITE_API_BASE_URL \
|
|
VITE_TOKEN_NAME=$VITE_TOKEN_NAME \
|
|
VITE_REFRESH_TOKEN_NAME=$VITE_REFRESH_TOKEN_NAME \
|
|
NODE_ENV=production
|
|
|
|
RUN npm run build
|
|
|
|
FROM nginx:stable-alpine AS production
|
|
|
|
# Use Alpine mirror for nginx image too
|
|
# RUN sed -i 's|https://dl-cdn.alpinelinux.org/alpine|https://mirror.de.velop.ir/alpine|g' /etc/apk/repositories
|
|
|
|
ENV TZ=Asia/Tehran
|
|
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
EXPOSE 80
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD wget -q --spider http://127.0.0.1/health || exit 1
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|