Skip to content

Commit

Permalink
添加github action打包跨平台镜像
Browse files Browse the repository at this point in the history
  • Loading branch information
Nriver committed Dec 22, 2023
1 parent 86f5fe2 commit 9121f53
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/docker-save-tag.yaml
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions Dockerfile_github_action
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9121f53

Please sign in to comment.