From 7bac7df87e35a8fe40707e5e60b87230ea874cac Mon Sep 17 00:00:00 2001 From: RockChinQ <1010553892@qq.com> Date: Thu, 27 Jun 2024 10:31:27 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20docker=E9=95=9C=E5=83=8F=E6=9E=84?= =?UTF-8?q?=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-docker-image.yaml | 46 +++++++++++++++++++++++ Dockerfile | 7 ++++ nginx/default.conf | 18 +++++++++ nginx/nginx.conf | 29 ++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 .github/workflows/build-docker-image.yaml create mode 100644 Dockerfile create mode 100644 nginx/default.conf create mode 100644 nginx/nginx.conf diff --git a/.github/workflows/build-docker-image.yaml b/.github/workflows/build-docker-image.yaml new file mode 100644 index 000000000..ada8f964e --- /dev/null +++ b/.github/workflows/build-docker-image.yaml @@ -0,0 +1,46 @@ +name: 构建文档Docker镜像 + +on: + push: + branches: + - main + +permissions: + contents: write + +jobs: + build-docker-image: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: 设置 Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: 安装 pnpm + run: | + npm install -g pnpm + + - name: 安装依赖 + run: + pnpm install + + - name: 构建文档 + env: + NODE_OPTIONS: --max_old_space_size=8192 + run: | + pnpm run docs:build + ls -R + + - name: Build image + run: | + docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/qchatgpt-wiki:latest . + - name: Publish image + run: | + docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_PASSWORD }} + docker push ${{ secrets.DOCKER_HUB_USERNAME }}/qchatgpt-wiki:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..c22a37ee4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM nginx:alpine + +COPY ./src/.vuepress/dist/ /usr/share/nginx/html/ +COPY ./nginx/nginx.conf /etc/nginx/nginx.conf +COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 \ No newline at end of file diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 000000000..39bde9415 --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,18 @@ +server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 000000000..acf29eb09 --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,29 @@ +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; +}