Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic build siyuan-community image and push to dockerhub and ghcr #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: Release Docker Image

on:
workflow_dispatch:
# push:
# branches:
# - master
create

jobs:
build:
Expand Down Expand Up @@ -47,6 +44,25 @@ jobs:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PWD }}

- name: Build the Docker image
run: |
docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8 -t b3log/siyuan:latest -t b3log/siyuan:v2.10.16 .
- name: Log in to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ vars.DOCKERHUB_REPOSITORY }}
ghcr.io/${{ github.repository }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8
push: true
tags: ${{ steps.meta.outputs.tags }}
20 changes: 10 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
FROM node:16 as NODE_BUILD
WORKDIR /go/src/github.com/siyuan-note/siyuan/
ADD . /go/src/github.com/siyuan-note/siyuan/
WORKDIR /go/src/github.com/siyuan-community/siyuan/
ADD . /go/src/github.com/siyuan-community/siyuan/
RUN cd app && npm install -g pnpm && pnpm install && pnpm run build

FROM golang:alpine as GO_BUILD
WORKDIR /go/src/github.com/siyuan-note/siyuan/
COPY --from=NODE_BUILD /go/src/github.com/siyuan-note/siyuan/ /go/src/github.com/siyuan-note/siyuan/
WORKDIR /go/src/github.com/siyuan-community/siyuan/
COPY --from=NODE_BUILD /go/src/github.com/siyuan-community/siyuan/ /go/src/github.com/siyuan-community/siyuan/
ENV GO111MODULE=on
ENV CGO_ENABLED=1
RUN apk add --no-cache gcc musl-dev git && \
cd kernel && go build --tags fts5 -v -ldflags "-s -w -X github.com/siyuan-note/siyuan/kernel/util.Mode=prod" && \
cd kernel && go build --tags fts5 -v -ldflags "-s -w -X github.com/siyuan-community/siyuan/kernel/util.Mode=prod" && \
mkdir /opt/siyuan/ && \
mv /go/src/github.com/siyuan-note/siyuan/app/appearance/ /opt/siyuan/ && \
mv /go/src/github.com/siyuan-note/siyuan/app/stage/ /opt/siyuan/ && \
mv /go/src/github.com/siyuan-note/siyuan/app/guide/ /opt/siyuan/ && \
mv /go/src/github.com/siyuan-note/siyuan/app/changelogs/ /opt/siyuan/ && \
mv /go/src/github.com/siyuan-note/siyuan/kernel/kernel /opt/siyuan/ && \
mv /go/src/github.com/siyuan-community/siyuan/app/appearance/ /opt/siyuan/ && \
mv /go/src/github.com/siyuan-community/siyuan/app/stage/ /opt/siyuan/ && \
mv /go/src/github.com/siyuan-community/siyuan/app/guide/ /opt/siyuan/ && \
mv /go/src/github.com/siyuan-community/siyuan/app/changelogs/ /opt/siyuan/ && \
mv /go/src/github.com/siyuan-community/siyuan/kernel/kernel /opt/siyuan/ && \
find /opt/siyuan/ -name .git | xargs rm -rf

FROM alpine:latest
Expand Down
Loading