+20
-7
@@ -1,22 +1,35 @@
|
|||||||
# مرحله اول: Builder
|
# Stage 1: Build
|
||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|
||||||
# کپی فایلهای اصلی
|
ARG NPM_REGISTRY=https://mirror-npm.runflare.com
|
||||||
|
|
||||||
|
# Vite embeds these at build time
|
||||||
|
ARG VITE_BASE_URL=https://dmenu-api.danakcorp.com
|
||||||
|
ARG VITE_SOCKET_URL=https://dmenu-api.danakcorp.com
|
||||||
|
ARG VITE_TOKEN_NAME=dmnu_a_t
|
||||||
|
ARG VITE_REFRESH_TOKEN_NAME=dmnu-a-rt
|
||||||
|
|
||||||
|
ENV VITE_BASE_URL=$VITE_BASE_URL \
|
||||||
|
VITE_SOCKET_URL=$VITE_SOCKET_URL \
|
||||||
|
VITE_TOKEN_NAME=$VITE_TOKEN_NAME \
|
||||||
|
VITE_REFRESH_TOKEN_NAME=$VITE_REFRESH_TOKEN_NAME
|
||||||
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# استفاده از رجیستری رانفلر با Fallback به رجیستری رسمی (برای اطمینان ۱۰۰٪)
|
RUN npm ci --registry="${NPM_REGISTRY}"
|
||||||
RUN npm ci --registry=https://mirror-npm.runflare.com || npm ci --registry=https://registry.npmjs.org
|
|
||||||
|
|
||||||
# کپی بقیه کدها و بیلد
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# مرحله دوم: Serving با Nginx
|
# Stage 2: Serve with Nginx
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
# کپی فایلهای تولید شده به Nginx
|
|
||||||
COPY --from=builder /build/dist /usr/share/nginx/html
|
COPY --from=builder /build/dist /usr/share/nginx/html
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|||||||
+13
-33
@@ -1,47 +1,27 @@
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name localhost;
|
server_name _;
|
||||||
|
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html;
|
index index.html;
|
||||||
|
|
||||||
add_header X-Frame-Options "DENY" always;
|
# SPA fallback
|
||||||
add_header X-Content-Type-Options "nosniff" always;
|
|
||||||
add_header X-XSS-Protection "1; mode=block" always;
|
|
||||||
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload" always;
|
|
||||||
# add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';" always;
|
|
||||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
||||||
|
|
||||||
location /static/ {
|
|
||||||
expires 1y;
|
|
||||||
add_header Cache-Control "public, no-transform";
|
|
||||||
}
|
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
try_files $uri $uri/ /index.html;
|
try_files $uri $uri/ /index.html;
|
||||||
expires -1;
|
|
||||||
add_header Cache-Control "no-store, no-cache, must-revalidate";
|
add_header Cache-Control "no-store, no-cache, must-revalidate";
|
||||||
}
|
}
|
||||||
|
|
||||||
# location /health {
|
# Vite build outputs to /assets by default
|
||||||
# access_log off;
|
location /assets/ {
|
||||||
# return 200;
|
expires 1y;
|
||||||
# }
|
add_header Cache-Control "public, immutable";
|
||||||
|
try_files $uri =404;
|
||||||
location ~ /\. {
|
|
||||||
deny all;
|
|
||||||
return 403;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error_page 500 502 503 504 /50x.html;
|
# optional: favicon (avoid noisy logs if missing)
|
||||||
location = /50x.html {
|
location = /favicon.ico {
|
||||||
root /usr/share/nginx/html;
|
try_files $uri =204;
|
||||||
internal;
|
access_log off;
|
||||||
|
log_not_found off;
|
||||||
}
|
}
|
||||||
|
|
||||||
gzip on;
|
|
||||||
gzip_vary on;
|
|
||||||
gzip_min_length 10240;
|
|
||||||
gzip_proxied expired no-cache no-store private auth;
|
|
||||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/javascript;
|
|
||||||
gzip_disable "MSIE [1-6]\.";
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user