mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-04 05:29:12 +08:00
更新 Release Docker Image 工作流 (#11122)
* Update dockerimage.yml * Update Dockerfile * Update Dockerfile
This commit is contained in:
parent
59ebc59190
commit
b8a898d919
41
.github/workflows/dockerimage.yml
vendored
41
.github/workflows/dockerimage.yml
vendored
@ -2,6 +2,11 @@ name: Release Docker Image
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
image_tag:
|
||||||
|
description: '镜像标签,留空则使用 package.json 中的版本号。务必注意:请确认选择了正确的分支。完整输入示例:3.0.11-rc0 '
|
||||||
|
required: true
|
||||||
|
default: ''
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
@ -10,12 +15,27 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
name: build
|
name: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
string:
|
||||||
|
- package_json: "app/package.json"
|
||||||
permissions:
|
permissions:
|
||||||
packages: write
|
packages: write
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
steps:
|
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)
|
- name: Free Disk Space (Ubuntu)
|
||||||
uses: jlumbroso/free-disk-space@main
|
uses: jlumbroso/free-disk-space@main
|
||||||
with:
|
with:
|
||||||
@ -32,21 +52,24 @@ jobs:
|
|||||||
docker-images: true
|
docker-images: true
|
||||||
swap-storage: true
|
swap-storage: true
|
||||||
|
|
||||||
- name: Check out the repo
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Setup Docker buildx
|
- name: Setup Docker buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_HUB_USER }}
|
username: ${{ secrets.DOCKER_HUB_USER }}
|
||||||
password: ${{ secrets.DOCKER_HUB_PWD }}
|
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: |
|
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
|
FROM node:21 as NODE_BUILD
|
||||||
WORKDIR /go/src/github.com/siyuan-note/siyuan/
|
WORKDIR /go/src/github.com/siyuan-note/siyuan/
|
||||||
ADD . /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
|
FROM golang:alpine as GO_BUILD
|
||||||
WORKDIR /go/src/github.com/siyuan-note/siyuan/
|
WORKDIR /go/src/github.com/siyuan-note/siyuan/
|
||||||
|
Loading…
Reference in New Issue
Block a user