diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 6261d6df..739d952b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -42,6 +42,8 @@ jobs: run: | deno task build deno task bundle + deno task compile server:dist:linux-x86_64 && mv silverbullet silverbullet-amd64 + deno task compile server:dist:linux-aarch64 && mv silverbullet silverbullet-arm64 - name: Login to Docker Hub uses: docker/login-action@v2 diff --git a/.github/workflows/edge.yml b/.github/workflows/edge.yml new file mode 100644 index 00000000..6bd1f0dc --- /dev/null +++ b/.github/workflows/edge.yml @@ -0,0 +1,36 @@ +name: Build & Release Edge + +on: + push: + branches: + - "main" +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Setup repo + uses: actions/checkout@v3 + - name: Setup Deno + uses: denoland/setup-deno@v2 + with: + deno-version: v2.3.5 + - name: Compile for all platforms + run: | + deno task server:zip:linux-x86_64 + deno task server:zip:linux-aarch64 + deno task server:zip:darwin-x86_64 + deno task server:zip:darwin-aarch64 + deno task server:zip:windows-x86_64 + - name: Update edge release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + draft: false + tag_name: edge + body: Automated build from commit ${{ github.sha }} + prerelease: false + files: | + website/CHANGELOG.md + dist/silverbullet.js + silverbullet-*.zip diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml index bdf41b98..400eedb0 100644 --- a/.github/workflows/server.yml +++ b/.github/workflows/server.yml @@ -27,11 +27,11 @@ jobs: - name: Compile for all platforms run: | - deno task server:dist:linux-x86_64 - deno task server:dist:linux-aarch64 - deno task server:dist:darwin-x86_64 - deno task server:dist:darwin-aarch64 - deno task server:dist:windows-x86_64 + deno task server:zip:linux-x86_64 + deno task server:zip:linux-aarch64 + deno task server:zip:darwin-x86_64 + deno task server:zip:darwin-aarch64 + deno task server:zip:windows-x86_64 - name: Release uses: softprops/action-gh-release@v1 diff --git a/.gitignore b/.gitignore index bc1993ef..ca9ef60f 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ node_modules *.db* test_space silverbullet +silverbullet-* deploy.json *.generated tmp_playground diff --git a/Dockerfile b/Dockerfile index 51d3ec8b..da3e22c8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM denoland/deno:debian-2.3.5 +FROM denoland/deno:alpine-2.3.5 # The volume that will keep the space data @@ -14,44 +14,29 @@ VOLUME /space # Accept TARGETARCH as argument ARG TARGETARCH -# Adding tini manually, as it's not included anymore in the new baseimage -ENV TINI_VERSION v0.19.0 +# Adding tini +ENV TINI_VERSION=v0.19.0 ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${TARGETARCH} /tini # Make sure the deno user has access to the space volume RUN mkdir -p -m 777 /space \ && chmod +x /tini \ - && apt update \ - && apt install -y git ssh-client pandoc texlive \ - && echo "**** cleanup ****" \ - && apt-get -y autoremove \ - && apt-get clean \ - && mkdir -p /deno-dir \ - && chmod 777 /deno-dir \ - && rm -rf \ - /tmp/* \ - /var/lib/apt/lists/* \ - /var/tmp/* \ - /var/log/* \ - /usr/share/man - + && apk add bash # 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 - -# Copy the bundled version of silverbullet into the container -ADD ./dist/silverbullet.js /silverbullet.js -# Precache any remaining dependencies -RUN deno cache /silverbullet.js +ENV SB_HOSTNAME=0.0.0.0 +ENV SB_FOLDER=/space # 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 ["/tini", "--", "/docker-entrypoint.sh"] diff --git a/deno.json b/deno.json index 0bba554c..602ead7d 100644 --- a/deno.json +++ b/deno.json @@ -33,7 +33,6 @@ "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", - "install-hooks": "./scripts/install_hooks.sh", "check": "find . -name '*.ts*' | xargs deno check", "lint": "deno lint", @@ -41,10 +40,11 @@ "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", + "build": "rm -rf dist dist_client_bundle dist_plug_bundle && deno run -A build_plugs.ts && deno run -A build_web.ts && 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", @@ -54,11 +54,17 @@ "bundle": "deno run -A build_bundle.ts", "compile": "deno task bundle && deno compile -A -o silverbullet dist/silverbullet.js", - "server:dist:linux-x86_64": "deno task bundle && deno compile -A --target x86_64-unknown-linux-gnu -o silverbullet dist/silverbullet.js && zip silverbullet-server-linux-x86_64.zip silverbullet", - "server:dist:linux-aarch64": "deno task bundle && deno compile -A --target aarch64-unknown-linux-gnu -o silverbullet dist/silverbullet.js && zip silverbullet-server-linux-aarch64 silverbullet", - "server:dist:darwin-x86_64": "deno task bundle && deno compile -A --target x86_64-apple-darwin -o silverbullet dist/silverbullet.js && zip silverbullet-server-darwin-x86_64.zip silverbullet", - "server:dist:darwin-aarch64": "deno task bundle && deno compile -A --target aarch64-apple-darwin -o silverbullet dist/silverbullet.js && zip silverbullet-server-darwin-aarch64.zip silverbullet", - "server:dist:windows-x86_64": "deno task bundle && deno compile -A --target x86_64-pc-windows-msvc -o silverbullet.exe dist/silverbullet.js && zip silverbullet-server-windows-x86_64.zip silverbullet.exe" + + "server:dist:linux-x86_64": "deno task bundle && deno compile -A --target x86_64-unknown-linux-gnu -o silverbullet dist/silverbullet.js", + "server:zip:linux-x86_64": "deno task server:dist:linux-x86_64 && zip silverbullet-server-linux-x86_64.zip silverbullet", + "server:dist:linux-aarch64": "deno task bundle && deno compile -A --target aarch64-unknown-linux-gnu -o silverbullet dist/silverbullet.js", + "server:zip:linux-aarch64": "deno task server:dist:linux-aarch64 && zip silverbullet-server-linux-aarch64.zip silverbullet", + "server:dist:darwin-x86_64": "deno task bundle && deno compile -A --target x86_64-apple-darwin -o silverbullet dist/silverbullet.js", + "server:zip:darwin-x86_64": "deno task server:dist:darwin-x86_64 && zip silverbullet-server-darwin-x86_64.zip silverbullet", + "server:dist:darwin-aarch64": "deno task bundle && deno compile -A --target aarch64-apple-darwin -o silverbullet dist/silverbullet.js", + "server:zip:darwin-aarch64": "deno task server:dist:darwin-aarch64 && zip silverbullet-server-darwin-aarch64.zip silverbullet", + "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" }, "lint": { "exclude": [ diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 4074286a..9b92cf55 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -13,7 +13,7 @@ fi if [ "$PUID" == "0" ] || [ "$UID" != "0" ]; then # Will run SilverBullet as default user - deno run -A /silverbullet.js $@ + /silverbullet $@ else # Create silverbullet user and group ad-hoc mapped to PUID and PGID getent group $PGID &> /dev/null || groupadd -g $PGID silverbullet @@ -24,6 +24,6 @@ else # And run via su as requested PUID, usually this will be 'silverbullet' but if a user with this idea already exists, we will use that USERNAME=$(getent passwd $PUID | cut -d ":" -f 1) echo "Running SilverBullet as $USERNAME (configured as PUID $PUID and PGID $PGID)" - su $USERNAME -s /bin/bash -c "deno run -A /silverbullet.js $args" + su $USERNAME -s /bin/bash -c "/silverbullet $args" fi diff --git a/scripts/build_docker.sh b/scripts/build_docker.sh index 849f99d7..52c655aa 100755 --- a/scripts/build_docker.sh +++ b/scripts/build_docker.sh @@ -1,4 +1,6 @@ #!/bin/sh -deno task bundle +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 . \ No newline at end of file diff --git a/scripts/install_hooks.sh b/scripts/install_hooks.sh deleted file mode 100755 index 16a4b6cf..00000000 --- a/scripts/install_hooks.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -# -# Script to set up Git hooks for SilverBullet -# - -# Get the directory where this script is located -SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -# Get the root directory of the repository -REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" - -# Create .git/hooks directory if it doesn't exist -mkdir -p "$REPO_ROOT/.git/hooks" - -# Make Git use the hooks in .githooks -git config core.hooksPath .githooks - -echo "Git hooks installed successfully from .githooks directory." -echo "To bypass hooks when committing, use 'git commit --no-verify'" \ No newline at end of file