diff --git a/.dockerignore b/.dockerignore index ea367ab..75b5cc7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,7 @@ node_modules dist .git +!deploy-dist.tar.gz .env.development .env.production .env.local diff --git a/.env.production b/.env.production index ac75434..ebc58ef 100644 --- a/.env.production +++ b/.env.production @@ -1 +1,3 @@ VITE_API_BASE_URL=https://nademitex.montest.ir/server/api +VITE_USE_MOCK_AUTH=false +VITE_BASE_PATH=/ diff --git a/.npmrc b/.npmrc index 30d4081..0f85696 100644 --- a/.npmrc +++ b/.npmrc @@ -1,8 +1,3 @@ -registry=https://registry.npmjs.org -replace-registry-host=always +registry=https://mirror2.chabokan.net/npm/ +replace-registry-host=npmjs legacy-peer-deps=true -fetch-retries=5 -fetch-retry-mintimeout=20000 -fetch-retry-maxtimeout=120000 -fetch-timeout=60000 -maxsockets=10 diff --git a/Dockerfile b/Dockerfile index 9f9ca62..35e31ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,20 @@ -FROM node:22 +FROM docker.iranserver.com/node:20 WORKDIR /app COPY package.json package-lock.json .npmrc ./ COPY scripts ./scripts -ENV NPM_CONFIG_REGISTRY=https://registry.npmjs.org -ENV NPM_CONFIG_FETCH_RETRIES=5 -ENV NPM_CONFIG_FETCH_RETRY_MINTIMEOUT=20000 -ENV NPM_CONFIG_FETCH_RETRY_MAXTIMEOUT=120000 -ENV NPM_CONFIG_FETCH_TIMEOUT=60000 -ENV NPM_CONFIG_MAXSOCKETS=10 +ENV NPM_CONFIG_REGISTRY=https://mirror2.chabokan.net/npm/ +RUN npm config set registry https://mirror2.chabokan.net/npm/ \ + && npm config set replace-registry-host npmjs \ + && npm config set fetch-retry-mintimeout 10000 \ + && npm config set fetch-retry-maxtimeout 120000 \ + && npm config set fetch-timeout 120000 \ + && npm config set fetch-retries 5 ENV NODE_ENV=development -RUN npm ci --include=dev --foreground-scripts --no-audit --no-fund --legacy-peer-deps +RUN npm ci --include=dev --foreground-scripts --no-audit --no-fund --legacy-peer-deps --registry=https://mirror2.chabokan.net/npm/ COPY . . diff --git a/deploy-dist.tar.gz b/deploy-dist.tar.gz new file mode 100644 index 0000000..ffd25b3 Binary files /dev/null and b/deploy-dist.tar.gz differ diff --git a/package.json b/package.json index 72ae649..0ece80c 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "build": "run-p type-check \"build-only {@}\" --", "preview": "vite preview", "build-only": "vite build", + "pack:docker": "node scripts/pack-docker.mjs", "type-check": "vue-tsc --build", "lint": "run-s \"lint:*\"", "lint:oxlint": "oxlint . --fix", diff --git a/scripts/pack-docker.mjs b/scripts/pack-docker.mjs new file mode 100644 index 0000000..bfde5a9 --- /dev/null +++ b/scripts/pack-docker.mjs @@ -0,0 +1,18 @@ +import { execSync } from 'node:child_process' +import { existsSync } from 'node:fs' +import path from 'node:path' +import { fileURLToPath } from 'node:url' + +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..') +process.chdir(root) + +execSync('node scripts/write-docker-vite-env.mjs', { stdio: 'inherit' }) +execSync('npm run build-only', { stdio: 'inherit' }) + +if (!existsSync(path.join(root, 'dist', 'index.html'))) { + throw new Error('dist/index.html ساخته نشد') +} + +const out = 'deploy-dist.tar.gz' +execSync(`tar -czf ${out} dist scripts/serve-user.mjs`, { stdio: 'inherit' }) +console.log(`packed ${out}`)