更新 Release Docker Image 工作流 (#11122)
* Update dockerimage.yml * Update Dockerfile * Update Dockerfile
This commit is contained in:
parent
59ebc59190
commit
b8a898d919
2 changed files with 47 additions and 10 deletions
41
.github/workflows/dockerimage.yml
vendored
41
.github/workflows/dockerimage.yml
vendored
|
@ -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:v3.0.11 .
|
||||
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:v${{ steps.version.outputs.value }} .
|
||||
|
||||
|
|
16
Dockerfile
16
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 pnpm@9.0.2 && 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/
|
||||
|
|
Loading…
Add table
Reference in a new issue