57 lines
1.7 KiB
Docker
57 lines
1.7 KiB
Docker
FROM node:20-alpine AS app-builder
|
|
USER root
|
|
WORKDIR /app
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV NEXT_PUBLIC_API_URL=https://api.canina.ir/api
|
|
|
|
# Optional: Use Nexus as npm registry
|
|
ARG NPM_REGISTRY=
|
|
RUN if [ -n "$NPM_REGISTRY" ]; then \
|
|
npm config set registry "$NPM_REGISTRY" && \
|
|
npm config set strict-ssl false; \
|
|
fi
|
|
|
|
COPY frontend/application/package*.json ./
|
|
RUN npm ci --include=dev --prefer-offline --no-audit
|
|
COPY frontend/application ./
|
|
ARG NEXT_PUBLIC_API_URL
|
|
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
|
|
RUN npm run build
|
|
|
|
FROM node:20-alpine AS admin-builder
|
|
USER root
|
|
WORKDIR /app
|
|
ENV VITE_API_URL=https://api.canina.ir/api
|
|
|
|
# Optional: Use Nexus as npm registry (inherits build-arg)
|
|
ARG NPM_REGISTRY=
|
|
RUN if [ -n "$NPM_REGISTRY" ]; then \
|
|
npm config set registry "$NPM_REGISTRY" && \
|
|
npm config set strict-ssl false; \
|
|
fi
|
|
|
|
COPY frontend/admin-panel/package*.json ./
|
|
RUN npm ci --include=dev --prefer-offline --no-audit
|
|
COPY frontend/admin-panel ./
|
|
ARG VITE_API_URL
|
|
ENV VITE_API_URL=$VITE_API_URL
|
|
RUN npm run build
|
|
|
|
FROM node:20-alpine
|
|
USER root
|
|
RUN addgroup -S nginx 2>/dev/null || true && adduser -S nginx -G nginx 2>/dev/null || true
|
|
RUN mkdir -p /var/log/nginx /var/cache/nginx /run/nginx /etc/nginx/conf.d /etc/nginx/http.d
|
|
COPY --from=nginx:alpine /etc/nginx /etc/nginx
|
|
COPY --from=nginx:alpine /usr/sbin/nginx /usr/sbin/nginx
|
|
COPY --from=nginx:alpine /usr/lib /usr/lib
|
|
COPY --from=nginx:alpine /lib /lib
|
|
RUN chown -R nginx:nginx /var/log/nginx /var/cache/nginx /run/nginx 2>/dev/null || true
|
|
WORKDIR /app
|
|
COPY --from=app-builder /app .
|
|
COPY --from=admin-builder /app/dist ./admin_static
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
COPY nginx.conf /etc/nginx/http.d/default.conf
|
|
|
|
EXPOSE 8080
|
|
CMD ["sh", "-c", "nginx && npm start"]
|