diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100755 index 00000000..685ef1f8 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,9 @@ +FROM nginx + +COPY ./dist /data + +RUN rm /etc/nginx/conf.d/default.conf + +ADD pigx-ui.conf /etc/nginx/conf.d/default.conf + +RUN /bin/bash -c 'echo init ok' \ No newline at end of file diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml new file mode 100755 index 00000000..12d7d62f --- /dev/null +++ b/docker/docker-compose.yaml @@ -0,0 +1,19 @@ +version: '3' +services: + pigx-ui: + build: + context: . + restart: always + container_name: pigx-ui + image: pigx-ui + networks: + - pigx_default + external_links: + - pigx-gateway + ports: + - 80:80 + +# 加入到后端网络, 默认为 pigx_default | docker network ls 查看 +networks: + pigx_default: + external: true \ No newline at end of file diff --git a/docker/pigx-ui.conf b/docker/pigx-ui.conf new file mode 100755 index 00000000..1477d935 --- /dev/null +++ b/docker/pigx-ui.conf @@ -0,0 +1,30 @@ +server { + listen 80; + server_name localhost; + + gzip on; + gzip_static on; # 需要http_gzip_static_module 模块 + gzip_min_length 1k; + gzip_comp_level 4; + gzip_proxied any; + gzip_types text/plain text/xml text/css; + gzip_vary on; + gzip_disable "MSIE [1-6]\.(?!.*SV1)"; + + # 前端打包好的dist目录文件 + root /data/; + + location ^~/api/ { + proxy_pass http://pigx-gateway:9999/; #注意/后缀 + proxy_connect_timeout 60s; + proxy_read_timeout 120s; + proxy_send_timeout 120s; + 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 http; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $http_host; + } +} diff --git a/package.json b/package.json index ed1d24e5..f9a35ced 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "scripts": { "dev": "vite --force", "build": "vite build", + "build:docker": "vite build --outDir ./docker/dist/", "lint:eslint": "eslint --fix --ext .js,.ts,.vue ./src", "prettier": "prettier --write ." },