Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

更新 Release Docker Image 工作流 (#11122)

绛亽b8a898d91993
diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml
index c45ba350fa..efbf09663e 100644
--- a/.github/workflows/dockerimage.yml
+++ b/.github/workflows/dockerimage.yml
@@ -2,6 +2,11 @@ name: Release Docker Image
on:
workflow_dispatch:
+ inputs:
+ image_tag:
+ description: '镜像标签,留空则使用 package.json 中的版本号。务必注意:请确认选择了正确的分支。完整输入示例:3.0.11-rc0 '
+ required: true
+ default: ''
push:
branches:
- master
@@ -10,12 +15,27 @@ jobs:
build:
name: build
runs-on: ubuntu-latest
-
+ strategy:
+ matrix:
+ string:
+ - package_json: "app/package.json"
permissions:
packages: write
contents: read
steps:
+ - name: Checkout repository and submodules
+ uses: actions/checkout@v4
+ with:
+ ref: ${{ github.event.ref }}
+ submodules: recursive
+
+ - name: Extract version from package.json
+ uses: sergeysova/jq-action@v2
+ id: version
+ with:
+ cmd: "jq .version ${{ matrix.string.package_json }} -r"
+
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
@@ -32,21 +52,24 @@ jobs:
docker-images: true
swap-storage: true
- - name: Check out the repo
- uses: actions/checkout@v3
-
- name: Set up QEMU
- uses: docker/setup-qemu-action@v2
+ uses: docker/setup-qemu-action@v3
- name: Setup Docker buildx
- uses: docker/setup-buildx-action@v2
+ uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
- uses: docker/login-action@v2
+ uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PWD }}
- - name: Build the Docker image
+ - name: Build the Docker image use Workflow Dispatch inputs' version
+ if: ${{ github.event_name == 'workflow_dispatch' && !github.event.inputs.image_tag == '' }}
+ run: |
+ docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8 -t b3log/siyuan:latest -t b3log/siyuan:v${{ github.event.inputs.image_tag }} .
+ - name: Build the Docker image use package_json version
+ if: ${{ github.event_name == 'push' || github.event.inputs.image_tag == '' }}
run: |
- docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8 -t b3log/siyuan:latest -t b3log/siyuan:v3.0.11 .
\ No newline at end of file
+ docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8 -t b3log/siyuan:latest -t b3log/siyuan:v${{ steps.version.outputs.value }} .
+
diff --git a/Dockerfile b/Dockerfile
index 0526f68c1a..f26b4495bf 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,7 +1,21 @@
FROM node:21 as NODE_BUILD
WORKDIR /go/src/github.com/siyuan-note/siyuan/
ADD . /go/src/github.com/siyuan-note/siyuan/
-RUN cd app && npm install -g [email protected] && pnpm install && pnpm run build
+RUN apt-get update && \
+ apt-get install -y jq
+RUN cd app && \
+packageManager=$(jq -r '.packageManager' package.json) && \
+if [ -n "$packageManager" ]; then \
+ npm install -g $packageManager; \
+else \
+ echo "No packageManager field found in package.json"; \
+ npm install -g pnpm; \
+fi && \
+pnpm install --registry=http://registry.npmjs.org/ --silent && \
+pnpm run build
+RUN apt-get purge -y jq
+RUN apt-get autoremove -y
+RUN rm -rf /var/lib/apt/lists/*
FROM golang:alpine as GO_BUILD
WORKDIR /go/src/github.com/siyuan-note/siyuan/