From 9121f5335dd0c061f98a6fdb7b4c43ec4b6d9f36 Mon Sep 17 00:00:00 2001 From: Nriver <6752679+Nriver@users.noreply.github.com> Date: Fri, 22 Dec 2023 14:11:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0github=20action=E6=89=93?= =?UTF-8?q?=E5=8C=85=E8=B7=A8=E5=B9=B3=E5=8F=B0=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-save-tag.yaml | 54 ++++++++++++++++++++++++++ .github/workflows/docker.yaml | 53 +++++++++++++++++++++++++ Dockerfile_github_action | 34 ++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 .github/workflows/docker-save-tag.yaml create mode 100644 .github/workflows/docker.yaml create mode 100644 Dockerfile_github_action diff --git a/.github/workflows/docker-save-tag.yaml b/.github/workflows/docker-save-tag.yaml new file mode 100644 index 0000000..76613fd --- /dev/null +++ b/.github/workflows/docker-save-tag.yaml @@ -0,0 +1,54 @@ +name: docker镜像tag存档 +on: + workflow_dispatch: #github页面手动触发 +jobs: + build-and-publish: + runs-on: ubuntu-latest + steps: + - name: Initialization environment + run : | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + sudo timedatectl set-timezone "Asia/Shanghai" + + - name: Checkout + uses: actions/checkout@main + with: + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + ref: main + + - name: Check and download remote files + run: | + wget https://github.com/Nriver/trilium-translation/releases/download/v0.62.4_20231222/trilium-cn-linux-x64-server.zip + # wget https://github.com/Nriver/trilium-translation/releases/latest/download/trilium-cn-linux-x64-server.zip + unzip -q trilium-cn-linux-x64-server.zip + rm -f trilium-cn-linux-x64-server.zip + sed -i '/electron/d' ./trilium-linux-x64-server/package.json + + - name: Show files + run: | + pwd + ls + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + file: ./Dockerfile_github_action + context: . + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/trilium-cn:0.62.4 + diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..088b0ff --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,53 @@ +name: 发布docker镜像 +on: + workflow_dispatch: #github页面手动触发 +jobs: + build-and-publish: + runs-on: ubuntu-latest + steps: + - name: Initialization environment + run : | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + sudo timedatectl set-timezone "Asia/Shanghai" + + - name: Checkout + uses: actions/checkout@main + with: + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + ref: main + + - name: Check and download remote files + run: | + wget https://github.com/Nriver/trilium-translation/releases/latest/download/trilium-cn-linux-x64-server.zip + unzip -q trilium-cn-linux-x64-server.zip + rm -f trilium-cn-linux-x64-server.zip + sed -i '/electron/d' ./trilium-linux-x64-server/package.json + + - name: Show files + run: | + pwd + ls + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + file: ./Dockerfile_github_action + context: . + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/trilium-cn:latest + diff --git a/Dockerfile_github_action b/Dockerfile_github_action new file mode 100644 index 0000000..ff3a66c --- /dev/null +++ b/Dockerfile_github_action @@ -0,0 +1,34 @@ +# Dockerfile for build up the image +FROM node:18.18.2-alpine + +LABEL MAINTAINER https://github.com/Nriver/trilium-translation + +ADD trilium-linux-x64-server /app +WORKDIR /app + +# 添加curl jq命令给health check使用 +# 合并RUN减少镜像层数 +# 减少镜像大小 purge清理包列表 +RUN apk add --virtual .build-dependencies \ + autoconf \ + automake \ + g++ \ + gcc \ + libtool \ + make \ + nasm \ + libpng-dev \ + python3 \ + && cp ./node_modules/@excalidraw/excalidraw/dist/excalidraw-assets/Virgil.woff2 ./Virgil.ttf \ + && rm -rf ./node_modules \ + && rm -rf ./node \ + && npm ci --production \ + && apk del .build-dependencies \ + && apk add curl jq \ + && npm prune --omit=dev \ + && mv -f ./Virgil.ttf ./node_modules/@excalidraw/excalidraw/dist/excalidraw-assets/Virgil.woff2 \ + && rm -rf /var/cache/apk/* \ + && rm -rf /var/log + +EXPOSE 8080 +CMD node /app/src/www