diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a8bc5b0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +node_modules +dist +.git +.gitignore +.env.local +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.DS_Store +*.md +.vscode +.idea \ No newline at end of file diff --git a/.env b/.env index 37f214b..d1bc400 100644 --- a/.env +++ b/.env @@ -1 +1,11 @@ -VITE_API_URL=https://api.simpletravel.uz/api/v1/ \ No newline at end of file +# API Configuration +VITE_API_URL=https://simple-travel.felixits.uz/api/v1/ +VITE_API_TIMEOUT=30000 + +# App Configuration +VITE_APP_NAME=simple-travel-admin +VITE_APP_VERSION=1.0.0 + +# Environment +NODE_ENV=production + diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..985148c --- /dev/null +++ b/.env.production @@ -0,0 +1,12 @@ +# API Configuration +VITE_API_URL=https://simple-travel.felixits.uz/api/v1/ +VITE_API_TIMEOUT=30000 + +# App Configuration +VITE_APP_NAME=simple-travel-admin +VITE_APP_VERSION=1.0.0 + +# Environment +NODE_ENV=production + + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..26ad7d6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# Build stage +FROM node:20-alpine + +WORKDIR /app + +# Copy dependencies +COPY package.json package-lock.json* ./ + +RUN npm ci --legacy-peer-deps + +# Copy all source +COPY . . + +# Set production env (agar .env.production bo‘lsa ishlaydi) +ENV NODE_ENV=production + +# Build for production +RUN npm run build +ENTRYPOINT npm run preview + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ad84c84 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +services: + simple-travel-admin: + build: + context: . + dockerfile: Dockerfile + args: + - VITE_API_URL=${VITE_API_URL} + - VITE_APP_NAME=${VITE_APP_NAME} + container_name: simple-travel-admin + ports: + - "5263:5263" + env_file: + - .env.production + restart: unless-stopped + networks: + - network + +networks: + network: + driver: bridge diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..5fe68ed --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,33 @@ +server { + listen 80; + server_name localhost; + root /usr/share/nginx/html; + index index.html; + + # Gzip compression + gzip on; + gzip_vary on; + gzip_min_length 1024; + gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/javascript application/json; + + # Security headers + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-XSS-Protection "1; mode=block" always; + + # React Router support + location / { + try_files $uri $uri/ /index.html; + } + + # Cache static assets + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # Don't cache index.html + location = /index.html { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + } +} \ No newline at end of file diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 0000000..818d468 --- /dev/null +++ b/stack.yaml @@ -0,0 +1,11 @@ +version: "3.9" + +services: + simple-travel-front-admin: + image: muhammadvadud/simple-travel-front-admin:latest + ports: + - "5263:3000" + deploy: + replicas: 2 + restart_policy: + condition: on-failure diff --git a/vite.config.ts b/vite.config.ts index 97895d8..00aa6fc 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -19,6 +19,12 @@ export default defineConfig({ host: true, port: 5173, }, + preview: { + host: true, // Production (vite preview) uchun + port: 5263, + allowedHosts: ["admin.simpletravel.uz"], // ✅ bu yer muhim + }, + build: { outDir: "dist", // Vercel build chiqishini shu papkadan oladi sourcemap: false, // Agar kerak bo‘lmasa o‘chirib qo‘ying