Browse Source
* feat: Docker support, including dynamic publish * fix: run container commandpull/2905/head
committed by
GitHub
10 changed files with 147 additions and 15 deletions
@ -0,0 +1,3 @@ |
|||
node_modules/ |
|||
dist/ |
|||
.vscode/ |
|||
@ -0,0 +1,22 @@ |
|||
# Whether to open mock |
|||
VITE_USE_MOCK = false |
|||
|
|||
# public path |
|||
VITE_PUBLIC_PATH = / |
|||
|
|||
# timeout(seconds) |
|||
VITE_TIMEOUT = 15 |
|||
# Delete console |
|||
VITE_DROP_CONSOLE = true |
|||
|
|||
# Whether to enable gzip or brotli compression |
|||
# Optional: gzip | brotli | none |
|||
# If you need multiple forms, you can use `,` to separate |
|||
VITE_BUILD_COMPRESS = 'none' |
|||
VITE_GLOB_API_URL="__vg_base_url" |
|||
|
|||
# File upload address, optional |
|||
# It can be forwarded by nginx or write the actual address directly |
|||
VITE_GLOB_UPLOAD_URL=/files/upload |
|||
# Interface prefix |
|||
VITE_GLOB_API_URL_PREFIX= |
|||
@ -0,0 +1,26 @@ |
|||
# node 构建 |
|||
FROM node:16-alpine as build-stage |
|||
# 署名 |
|||
MAINTAINER Adoin 'adoin@qq.com' |
|||
WORKDIR /app |
|||
COPY . ./ |
|||
# 设置 node 阿里镜像 |
|||
RUN npm config set registry https://registry.npm.taobao.org |
|||
# 设置--max-old-space-size |
|||
ENV NODE_OPTIONS=--max-old-space-size=16384 |
|||
# 设置阿里镜像、pnpm、依赖、编译 |
|||
RUN npm install pnpm -g && \ |
|||
pnpm install --frozen-lockfile && \ |
|||
pnpm build:docker |
|||
# node部分结束 |
|||
RUN echo "🎉 编 🎉 译 🎉 成 🎉 功 🎉" |
|||
# nginx 部署 |
|||
FROM nginx:1.23.3-alpine as production-stage |
|||
COPY --from=build-stage /app/dist /usr/share/nginx/html/dist |
|||
COPY --from=build-stage /app/nginx.conf /etc/nginx/nginx.conf |
|||
EXPOSE 80 |
|||
## 将/usr/share/nginx/html/dist/assets/index.js 和/usr/share/nginx/html/dist/_app.config.js中的"$vg_base_url"替换为环境变量中的VG_BASE_URL,$vg_sub_domain 替换成VG_SUB_DOMAIN,$vg_default_user替换成VG_DEFAULT_USER,$vg_default_password替换成VG_DEFAULT_PASSWORD 而后启动nginx |
|||
CMD sed -i "s|__vg_base_url|$VG_BASE_URL|g" /usr/share/nginx/html/dist/assets/index.js && \ |
|||
sed -i "s|__vg_base_url|$VG_BASE_URL|g" /usr/share/nginx/html/dist/_app.config.js && \ |
|||
nginx -g 'daemon off;' |
|||
RUN echo "🎉 架 🎉 设 🎉 成 🎉 功 🎉" |
|||
@ -0,0 +1,37 @@ |
|||
#user nobody; |
|||
worker_processes 1; |
|||
|
|||
#error_log logs/error.log; |
|||
#error_log logs/error.log notice; |
|||
#error_log logs/error.log info; |
|||
|
|||
#pid logs/nginx.pid; |
|||
|
|||
|
|||
events { |
|||
worker_connections 1024; |
|||
} |
|||
|
|||
|
|||
http { |
|||
include mime.types; |
|||
default_type application/octet-stream; |
|||
server { |
|||
listen 80; |
|||
location / { |
|||
root /usr/share/nginx/html/dist; |
|||
try_files $uri $uri/ /index.html; |
|||
index index.html; |
|||
# Enable CORS |
|||
add_header 'Access-Control-Allow-Origin' '*'; |
|||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; |
|||
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; |
|||
if ($request_method = 'OPTIONS') { |
|||
add_header 'Access-Control-Max-Age' 1728000; |
|||
add_header 'Content-Type' 'text/plain charset=UTF-8'; |
|||
add_header 'Content-Length' 0; |
|||
return 204; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue