From 3a37c1113bf123fa08f947c69d3441ad2c9b074b Mon Sep 17 00:00:00 2001 From: TeamsSix <49087564+teamssix@users.noreply.github.com> Date: Fri, 12 Aug 2022 17:06:31 +0800 Subject: [PATCH] ci: add docker build ci --- .github/workflows/docker-image.yml | 34 ++++++++++++++++++++++++++++++ Dockerfile | 7 ++++++ README.md | 21 +++++++++--------- 3 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/docker-image.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..06ddc5d --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,34 @@ +name: Publish Docker image +on: + push: + branches: + - 'main' + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3 + with: + images: teamssix/twiki + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..416d260 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM node:12.22.12 +LABEL maintainer="teamssix " +COPY . /TWiki +WORKDIR /TWiki +RUN yarn install && yarn docs:build +FROM nginx:alpine +COPY --from=0 /TWiki/docs/.vuepress/dist/ /usr/share/nginx/html/ \ No newline at end of file diff --git a/README.md b/README.md index 372ad9a..7defceb 100644 --- a/README.md +++ b/README.md @@ -8,17 +8,9 @@ 文库的地址为:[wiki.teamssix.com](https://wiki.teamssix.com/) -## 本地开发预览 +## 本地部署 -```bash -git clone https://github.com/teamssix/TWiki.git --depth 1 -cd TWiki -npm install --global yarn -yarn install -yarn docs:dev -``` - -## 生成并部署 +> 注意:node 版本需要大于或等于 12 ```bash git clone https://github.com/teamssix/TWiki.git --depth 1 @@ -30,7 +22,14 @@ yarn docs:build build 完之后,将 docs/.vuepress/dist 目录下的文件复制到你的 nginx 或者 apache 服务的网站根目录下即可。 -> 注意:node 版本需要大于或等于 12 +## Docker 部署 + +```bash +docker pull teamssix/twiki +docker run --name twiki -d -p 7777:80 twiki +``` + +然后访问本地 IP 的 7777 端口即可。 ## 感谢以下为 T Wiki 文库贡献的师傅们 :confetti_ball: