Replaces hacky way of building two binaries for ARM and Intel and putting the right one into the image by using a multi-stage build. You can now build SB without even installing Deno.

Also adds a HEALTCHECK
This commit is contained in:
Zef Hemel
2025-09-01 09:09:16 +02:00
parent 3aad24cc70
commit 644e027abe
4 changed files with 53 additions and 35 deletions
+15 -2
View File
@@ -1,3 +1,14 @@
FROM denoland/deno:2.4.5 AS builder
RUN apt update && apt install -y curl git
WORKDIR /app
ADD . /app
RUN deno task build
FROM ubuntu:noble
# The volume that will keep the space data
@@ -20,11 +31,13 @@ ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${TAR
RUN mkdir -p -m 777 /space \
&& chmod +x /tini \
&& apt update \
&& apt install -y git \
&& apt install -y git curl \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /tmp/* /var/tmp/* /var/log/* /usr/share/man /var/lib/apt/lists/*
HEALTHCHECK CMD curl --fail http://localhost:3000/.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
@@ -37,7 +50,7 @@ ENV SB_FOLDER=/space
ADD ./docker-entrypoint.sh /docker-entrypoint.sh
# Copy the bundled version of silverbullet into the container
ADD silverbullet-${TARGETARCH} /silverbullet
COPY --from=builder /app/silverbullet /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
+12
View File
@@ -73,4 +73,16 @@ deno task watch-plugs
To typecheck the entire codebase (recommended before submitting PR):
```shell
deno task check
```
To build it in a docker container:
```shell
docker build -t silverbullet .
```
and to then run it:
```shell
docker run -p 3000:3000 -v <PATH-TO-YOUR-SPACE>:/space silverbullet
```
+26 -27
View File
@@ -1,32 +1,8 @@
{
"name": "@silverbulletmd/silverbullet",
"version": "2.0.0",
"exports": {
"./syscall": "./plug-api/syscall.ts",
"./syscalls": "./plug-api/syscalls.ts",
"./lib/json": "./plug-api/lib/json.ts",
"./lib/tree": "./plug-api/lib/tree.ts",
"./lib/attribute": "./plug-api/lib/attribute.ts",
"./lib/ref": "./plug-api/lib/ref.ts",
"./lib/resolve": "./plug-api/lib/resolve.ts",
"./lib/frontmatter": "./plug-api/lib/frontmatter.ts",
"./type/client": "./type/client.ts",
"./type/command": "./type/command.ts",
"./type/config": "./type/config.ts",
"./type/datastore": "./type/datastore.ts",
"./type/event": "./type/event.ts",
"./type/index": "./type/index.ts",
"./type/rpc": "./type/rpc.ts",
"./lib/tags": "./plug-api/lib/tags.ts"
},
"publish": {
"exclude": [
"website",
"CHANGELOG.md",
"**/*.md"
]
},
"tasks": {
"build": "rm -rf dist dist_client_bundle dist_plug_bundle && deno run -A build_plugs.ts && deno run -A build_web.ts --production && deno task compile",
"clean": "rm -rf dist dist_client_bundle dist_plug_bundle",
"deep-clean-mac": "rm -f deno.lock && rm -rf $HOME/Library/Caches/deno && deno task clean",
"install": "deno install -g -f -A --import-map deno.json silverbullet.ts",
@@ -35,11 +11,9 @@
"fmt": "deno fmt",
"test": "deno test -A",
"bench": "deno bench",
"build": "rm -rf dist dist_client_bundle dist_plug_bundle && deno run -A build_plugs.ts && deno run -A build_web.ts --production && deno task compile",
"plugs": "deno run -A build_plugs.ts",
"server": "deno run -A --check silverbullet.ts",
"generate": "./scripts/generate.sh",
"docker": "./scripts/build_docker.sh",
"watch-web": "deno run -A --check build_web.ts --watch",
"watch-server": "deno run -A --check --watch silverbullet.ts",
"watch-plugs": "deno run -A --check build_plugs.ts -w",
@@ -57,6 +31,13 @@
"server:dist:windows-x86_64": "deno task bundle && deno compile -A --target x86_64-pc-windows-msvc -o silverbullet.exe dist/silverbullet.js",
"server:zip:windows-x86_64": "deno task server:dist:windows-x86_64 && zip silverbullet-server-windows-x86_64.zip silverbullet.exe"
},
"publish": {
"exclude": [
"website",
"CHANGELOG.md",
"**/*.md"
]
},
"lint": {
"exclude": [
"dist",
@@ -94,6 +75,24 @@
"jsx": "react-jsx",
"jsxImportSource": "npm:preact@10.26.4"
},
"exports": {
"./syscall": "./plug-api/syscall.ts",
"./syscalls": "./plug-api/syscalls.ts",
"./lib/json": "./plug-api/lib/json.ts",
"./lib/tree": "./plug-api/lib/tree.ts",
"./lib/attribute": "./plug-api/lib/attribute.ts",
"./lib/ref": "./plug-api/lib/ref.ts",
"./lib/resolve": "./plug-api/lib/resolve.ts",
"./lib/frontmatter": "./plug-api/lib/frontmatter.ts",
"./type/client": "./type/client.ts",
"./type/command": "./type/command.ts",
"./type/config": "./type/config.ts",
"./type/datastore": "./type/datastore.ts",
"./type/event": "./type/event.ts",
"./type/index": "./type/index.ts",
"./type/rpc": "./type/rpc.ts",
"./lib/tags": "./plug-api/lib/tags.ts"
},
"imports": {
"@cliffy/command": "jsr:@cliffy/command@^1.0.0-rc.7",
"@cliffy/prompt": "jsr:@cliffy/prompt@^1.0.0-rc.7",
-6
View File
@@ -1,6 +0,0 @@
#!/bin/sh
echo "Building both AMD64 and ARM64 Linux binaries"
deno task server:dist:linux-x86_64 && mv silverbullet silverbullet-amd64
deno task server:dist:linux-aarch64 && mv silverbullet silverbullet-arm64
docker build -t silverbullet .