feat: add dockeriz project
This commit is contained in:
42
.dockerignore
Normal file
42
.dockerignore
Normal file
@@ -0,0 +1,42 @@
|
||||
# Dependencies
|
||||
node_modules
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
# Build output
|
||||
dist
|
||||
dist-ssr
|
||||
build
|
||||
.next
|
||||
|
||||
# Stale Next.js experiment (not used by the Vite build)
|
||||
app
|
||||
|
||||
# VCS / CI
|
||||
.git
|
||||
.gitignore
|
||||
.github
|
||||
|
||||
# Docker
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
docker-compose*.yml
|
||||
|
||||
# Env / secrets
|
||||
.env
|
||||
.env.*
|
||||
!.env.production
|
||||
build.sh
|
||||
|
||||
# Editor / OS
|
||||
.vscode
|
||||
.idea
|
||||
.DS_Store
|
||||
*.local
|
||||
*.log
|
||||
|
||||
# Misc
|
||||
README.md
|
||||
bun.lockb
|
||||
36
Dockerfile
Normal file
36
Dockerfile
Normal file
@@ -0,0 +1,36 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
# ---------- Build stage ----------
|
||||
FROM node:20-alpine AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies (cached unless package files change)
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
# Build the app
|
||||
COPY . .
|
||||
|
||||
# API base URL is baked in at build time (Vite inlines VITE_* vars).
|
||||
# Override with: docker build --build-arg VITE_API_URL=https://api.example.com/api/v1 .
|
||||
ARG VITE_API_URL
|
||||
ENV VITE_API_URL=$VITE_API_URL
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# ---------- Runtime stage ----------
|
||||
FROM nginx:alpine AS runtime
|
||||
|
||||
# SPA-aware nginx config
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Static build output
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD wget -q -O /dev/null http://127.0.0.1/ || exit 1
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
61
nginx.conf
Normal file
61
nginx.conf
Normal file
@@ -0,0 +1,61 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# ---- gzip ----
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_types
|
||||
text/plain
|
||||
text/css
|
||||
text/javascript
|
||||
application/javascript
|
||||
application/json
|
||||
application/xml
|
||||
application/rss+xml
|
||||
image/svg+xml
|
||||
font/ttf
|
||||
font/otf
|
||||
font/woff
|
||||
font/woff2
|
||||
application/vnd.ms-fontobject;
|
||||
|
||||
# ---- Hashed static assets: cache hard ----
|
||||
# ^~ so this wins over the regex block below for Vite's fingerprinted files
|
||||
location ^~ /assets/ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# ---- Other static files by extension ----
|
||||
location ~* \.(?:js|css|png|jpe?g|gif|webp|avif|svg|ico|woff2?|ttf|otf|eot|mp4|webm)$ {
|
||||
expires 30d;
|
||||
add_header Cache-Control "public";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# ---- SPA fallback: unknown routes -> index.html (React Router) ----
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# index.html must never be cached, so new deploys are picked up
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
expires -1;
|
||||
}
|
||||
|
||||
# Don't log noise / don't cache the favicon aggressively is fine as-is
|
||||
location = /favicon.ico {
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
expires 30d;
|
||||
}
|
||||
}
|
||||
6044
package-lock.json
generated
Normal file
6044
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,8 @@ const useAxios = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const instance = axios.create({
|
||||
baseURL: "https://api.persain-game.com/api/v1",
|
||||
baseURL:
|
||||
import.meta.env.VITE_API_URL ?? "https://api.persain-game.com/api/v1",
|
||||
maxBodyLength: Infinity,
|
||||
...(sessionStorage.getItem("shop_id") && {
|
||||
headers: {
|
||||
|
||||
8
src/vite-env.d.ts
vendored
8
src/vite-env.d.ts
vendored
@@ -1 +1,9 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_API_URL?: string;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user