This commit is contained in:
+13
-10
@@ -1,6 +1,7 @@
|
|||||||
|
# مرحله اول: Builder
|
||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
# Use Liara Alpine mirror for restricted environments
|
# تنظیم مخازن آلپاین برای سرعت بیشتر در ایران (اختیاری - همان که داشتید)
|
||||||
RUN sed -i 's|https://dl-cdn.alpinelinux.org|https://mirror.de.velop.ir|g' /etc/apk/repositories \
|
RUN sed -i 's|https://dl-cdn.alpinelinux.org|https://mirror.de.velop.ir|g' /etc/apk/repositories \
|
||||||
&& apk add --no-cache tzdata \
|
&& apk add --no-cache tzdata \
|
||||||
&& cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime \
|
&& cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime \
|
||||||
@@ -8,20 +9,22 @@ RUN sed -i 's|https://dl-cdn.alpinelinux.org|https://mirror.de.velop.ir|g' /etc/
|
|||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|
||||||
|
# کپی کردن فایلهای تنظیمات ابتدا برای استفاده از کش لایهها
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
# Use Liara npm mirror
|
|
||||||
RUN npm ci --registry=https://package-mirror.liara.ir
|
|
||||||
|
|
||||||
COPY . ./
|
# استفاده از رجیستری رسمی برای دسترسی به آخرین نسخه پکیجها
|
||||||
|
RUN npm ci --registry=https://registry.npmjs.org
|
||||||
|
|
||||||
|
# کپی بقیه کدها
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# اجرای بیلد
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# ---
|
# مرحله دوم: Serving (مثلاً با Nginx)
|
||||||
|
FROM nginx:alpine
|
||||||
FROM nginx:stable-alpine AS production-stage
|
# کپی فایلهای بیلد شده از مرحله قبل به پوشه پیشفرض nginx
|
||||||
|
|
||||||
COPY --from=builder /build/dist /usr/share/nginx/html
|
COPY --from=builder /build/dist /usr/share/nginx/html
|
||||||
COPY --from=builder /build/nginx.conf /etc/nginx/conf.d/default.conf
|
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|||||||
Reference in New Issue
Block a user