diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..dd3f119 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +node_modules +dist +dist-ssr +.git +.idea +.vscode +*.log +Dockerfile +docker-compose.yml +README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..788a534 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM node:24-alpine AS build + +WORKDIR /app + +RUN corepack enable + +COPY package.json pnpm-lock.yaml ./ +RUN pnpm install --frozen-lockfile + +COPY . . + +ARG VITE_BASE_URL=http://twin.batiao8.com +ARG VITE_APP_ID=10063 +ENV VITE_BASE_URL=$VITE_BASE_URL +ENV VITE_APP_ID=$VITE_APP_ID + +RUN pnpm build + +FROM nginx:1.27-alpine AS runtime + +COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=build /app/dist /usr/share/nginx/html + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e0c724a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +services: + app-twins: + build: + context: . + args: + VITE_BASE_URL: http://twin.batiao8.com + VITE_APP_ID: "10063" + image: app-twins:latest + container_name: app-twins + restart: unless-stopped + ports: + - "8080:80" diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..b600d1c --- /dev/null +++ b/nginx.conf @@ -0,0 +1,20 @@ +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + location /api/ { + proxy_pass http://twin.batiao8.com/api/; + proxy_http_version 1.1; + proxy_set_header Host twin.batiao8.com; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location / { + try_files $uri $uri/ /index.html; + } +}