From dcf4f126e61b75992c2c8e0e8d9bfa48f01a9b9d Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 6 Feb 2026 14:49:20 +0100 Subject: [PATCH] Fix docker builds --- .github/workflows/docker.yml | 19 +++++++++++++++--- Dockerfile | 2 +- Dockerfile.ci | 39 ++++++++++++++++++++++++++++++++++++ Makefile | 9 ++++++++- plugs/index/link.ts | 2 +- 5 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 Dockerfile.ci diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1ab3e9fe..e85ee0f8 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -9,7 +9,7 @@ on: - "*" env: # Docker & Registries - ARCHITECTURES: linux/amd64,linux/arm64 + ARCHITECTURES: linux/arm64,linux/amd64 IMAGE_NAME: silverbullet WEBSITE_IMAGE: zefhemel/silverbullet-website NAMESPACE_GITHUB: silverbulletmd @@ -48,6 +48,19 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Setup Deno + uses: denoland/setup-deno@v2 + with: + deno-version: v2.6.8 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: "1.25.1" + + - name: Build binaries for multiple platforms + run: | + make build-for-docker + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v4.4.0 @@ -67,12 +80,12 @@ jobs: type=raw,value=v2,enable=${{ github.ref == 'refs/heads/main' }} - name: Build and push main docker images - uses: docker/build-push-action@v4.0.0 + uses: docker/build-push-action@v6.18.0 with: context: . platforms: ${{ env.ARCHITECTURES }} push: true - file: Dockerfile + file: Dockerfile.ci provenance: false tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 432bec41..e19fc73f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,7 @@ VOLUME /space # Or simply mount an existing folder into the container: # docker run -v /path/to/my/folder:/space -p3000:3000 -it ghcr.io/silverbulletmd/silverbullet -RUN apk add --no-cache git curl bash tini +RUN apk add --no-cache git curl bash tini libc6-compat HEALTHCHECK CMD curl --fail http://localhost:$SB_PORT$SB_URL_PREFIX/.ping || exit 1 diff --git a/Dockerfile.ci b/Dockerfile.ci new file mode 100644 index 00000000..b7d22ba9 --- /dev/null +++ b/Dockerfile.ci @@ -0,0 +1,39 @@ +FROM alpine:latest + +# The volume that will keep the space data +VOLUME /space + +ARG TARGETARCH + +# Either create a volume: +# docker volume create myspace +# Then bind-mount it when running the container with the -v flag, e.g.: +# docker run -v myspace:/space -p3000:3000 -it ghcr.io/silverbulletmd/silverbullet +# Or simply mount an existing folder into the container: +# docker run -v /path/to/my/folder:/space -p3000:3000 -it ghcr.io/silverbulletmd/silverbullet + +RUN apk add --no-cache git curl bash tini libc6-compat + +HEALTHCHECK CMD curl --fail http://localhost:$SB_PORT$SB_URL_PREFIX/.ping || exit 1 + +# Expose port 3000 +# Port map this when running, e.g. with -p 3002:3000 (where 3002 is the host port) +EXPOSE 3000 + +# Always binding to this IP, otherwise the server wouldn't be available +ENV SB_HOSTNAME=0.0.0.0 +ENV SB_FOLDER=/space +ENV SB_PORT=3000 + +# Reset /etc/group and /etc/passwd +RUN echo "" > /etc/group && echo "root:x:0:0:root:/root:/bin/sh" > /etc/passwd + +# As well as the docker-entrypoint.sh script +ADD ./docker-entrypoint.sh /docker-entrypoint.sh + +# Copy the bundled version of silverbullet into the container +ADD silverbullet-${TARGETARCH} /silverbullet + +# Run the server, allowing to pass in additional argument at run time, e.g. +# docker run -p 3002:3000 -v myspace:/space -it ghcr.io/silverbulletmd/silverbullet --user me:letmein +ENTRYPOINT ["/sbin/tini", "--", "/docker-entrypoint.sh"] diff --git a/Makefile b/Makefile index 231e7091..cb029597 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,16 @@ build: # Build server go build +build-for-docker: build + GOOS=linux GOARCH=arm64 go build -o silverbullet-arm64 . + GOOS=linux GOARCH=amd64 go build -o silverbullet-amd64 . + +docker: build-for-docker + docker buildx build --platform linux/arm64,linux/amd64 --push . + clean: rm -rf client_bundle/{base_fs,client} dist public_version.ts - rm -f silverbullet + rm -f silverbullet silverbullet-arm64 silverbullet-amd64 check: # Frontend type check diff --git a/plugs/index/link.ts b/plugs/index/link.ts index e0231360..241ba05d 100644 --- a/plugs/index/link.ts +++ b/plugs/index/link.ts @@ -205,7 +205,7 @@ export async function indexLinks( if (alias) { link.alias = alias; } - updateITags(link as LinkObject, frontmatter); + updateITags(link, frontmatter); objects.push(link); } }