From 38460974eeb030c2f3994113524baee5e4f5bf42 Mon Sep 17 00:00:00 2001 From: Doocs Bot Date: Mon, 23 Dec 2024 18:30:11 +0800 Subject: [PATCH 1/3] Update Dockerfile --- Dockerfile | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2fc343b9c9600..b1afcfa01f984 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,11 @@ -# Use Node.js version 14 as the base image -FROM node:14 +# 使用官方的 Nginx 镜像作为基础镜像 +FROM nginx:alpine -# Set the working directory inside the container -WORKDIR /app +# 将构建的静态文件拷贝到 Nginx 的默认站点目录 +COPY site /usr/share/nginx/html -# Copy package.json and package-lock.json (if present) to the working directory -COPY package*.json ./ - -# Install npm dependencies -RUN npm install - -# Copy all files from the current directory to the working directory in the container -COPY . . - -# Expose port 80 to allow communication to/from the container +# 暴露 80 端口 EXPOSE 80 -# Specify the command to run the application -CMD ["npm", "start"] +# 默认启动 Nginx 服务 +CMD ["nginx", "-g", "daemon off;"] From fb4a1ff36826369162b27bf285c6dc4f42762fc6 Mon Sep 17 00:00:00 2001 From: Doocs Bot Date: Mon, 23 Dec 2024 18:38:01 +0800 Subject: [PATCH 2/3] Create test.yml --- .github/workflows/test.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000000000..23655e5fc7d10 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,31 @@ +name: test + +on: + push: + branches: + - main + workflow_dispatch: + +env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + DOCKER_REPO: doocs/leetcode + + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: gh-pages + path: site + - name: Build Docker Image + run: | + docker build -t ${{ env.DOCKER_REPO }}:latest . + - name: Login to DockerHub + run: | + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin + - name: Push Docker Image to DockerHub + run: | + docker push ${{ env.DOCKER_REPO }}:latest From 645444b63e387fdf815e81dd557379baa78934de Mon Sep 17 00:00:00 2001 From: Doocs Bot Date: Mon, 23 Dec 2024 18:44:31 +0800 Subject: [PATCH 3/3] Update test.yml --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 23655e5fc7d10..adb222c225a45 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,10 +16,13 @@ jobs: deploy: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - uses: actions/checkout@v4 with: ref: gh-pages path: site + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - name: Build Docker Image run: | docker build -t ${{ env.DOCKER_REPO }}:latest .