Deno docker update (#174)

Fix #150: update Dockerfile and docker-compose
pull/176/head
Zef Hemel 2022-12-07 18:43:47 +01:00 committed by GitHub
parent acec440444
commit 5b8c25f8b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 109 additions and 27 deletions

36
.github/workflows/docker.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: Docker
on:
push:
branches: ["main"]
jobs:
docker-build-push:
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
- name: Setup Deno
uses: denoland/setup-deno@d4873ceeec10de6275fecd1f94b6985369d40231
with:
deno-version: v1.28.1
- name: Run bundle build
run: |
deno task build
deno task bundle
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: zefhemel/silverbullet:latest

View File

@ -1,12 +1,4 @@
# This workflow uses actions that are not certified by GitHub. name: Test
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will install Deno then run Deno lint and test.
# For more information see: https://github.com/denoland/setup-deno
name: Deno
on: on:
push: push:

View File

@ -1,12 +1,26 @@
FROM node:18.6.0-slim FROM denoland/deno:alpine-1.28.3
RUN mkdir /space # The volume that will keep the space data
RUN chown node:node /space # Create a volume first:
USER node # docker volume create myspace
WORKDIR /space # Then bind-mount it when running the container with the -v flag, e.g.:
# docker run -v myspace:/space -it zefhemel/silverbullet
VOLUME /space
RUN npx --yes @silverbulletmd/server || true # Copy the bundled version of silverbullet into the container
ADD ./dist/silverbullet.js /silverbullet.js
# Make sure the deno user has access to the space volume
RUN mkdir -p /space
RUN chown -R deno:deno /space
# deno user id is 1000 in alpine image
USER deno
# Expose port 3000
# Port map this when running, e.g. with -p 3002:3000 (where 3002 is the host port)
EXPOSE 3000 EXPOSE 3000
CMD ["sh","-c","npx --yes @silverbulletmd/server --port 3000 /space"] # Run the server, allowing to pass in additional argument at run time, e.g.
# docker run -p 3002:3000 -v myspace:/space -it zefhemel/silverbullet --user me:letmein
ENTRYPOINT ["/tini", "--", "deno", "run", "-A", "--unstable", "/silverbullet.js", "/space"]

View File

@ -40,7 +40,7 @@ Or checkout these two videos:
[plugs](https://silverbullet.md/🔌_Plugs), and you can customize it to your [plugs](https://silverbullet.md/🔌_Plugs), and you can customize it to your
liking and your workflows. liking and your workflows.
## Installing Silver Bullet ## Installing Silver Bullet with Deno
### Installing Deno ### Installing Deno
@ -101,6 +101,37 @@ Simply run this:
And restart Silver Bullet. You should be good to go. And restart Silver Bullet. You should be good to go.
## Installing Silver Bullet with Docker
There is a [docker image on docker hub](https://hub.docker.com/r/zefhemel/silverbullet). To use it, first create a volume to keep your space (markdown) files:
```shell
docker volume create myspace
```
Then, run the container, e.g. as follows:
```shell
docker run -p 3000:3000 -v myspace:/space -d --name silverbullet zefhemel/silverbullet
```
If you'd like to pass in additional command line arguments (e.g. `--user` to add authentication) you can just append those to the command, e.g.:
```shell
docker run -p 3000:3000 -v myspace:/space -d --name silverbullet zefhemel/silverbullet --user me:letmein
```
To build your own version of the docker image, run `./scripts/build_docker.sh`.
You can also use docker-compose if you prefer. From a silverbullet check-out run:
```shell
deno task bundle
PORT=3000 docker-compose up
```
or similar.
## Troubleshooting ## Troubleshooting
If you upgraded to the new Deno-based Silver Bullet from an old version, you may If you upgraded to the new Deno-based Silver Bullet from an old version, you may

View File

@ -1,11 +1,13 @@
services: services:
sb: silverbullet:
build: ./ image: zefhemel/silverbullet
image: sb container_name: silverbullet
container_name: sb restart: unless-stopped
## To enable additional options, such as BasicAuth, uncomment the following line:
# command: --user='user:pw'
volumes:
- space:/space
ports: ports:
- ${PORT}:3000 - ${PORT}:3000
volumes: volumes:
- type: bind space:
source: ${DIRECTORY}
target: /space

4
scripts/build_docker.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
deno task bundle
docker build -t zefhemel/silverbullet .

View File

@ -58,6 +58,10 @@ export function cleanWikiLinkPlugin(editor: Editor) {
break; break;
} }
} }
if (cleanPage === "") {
// Empty page name, or local @anchor use
pageExists = true;
}
if (isCursorInRange(view.state, [from, to])) { if (isCursorInRange(view.state, [from, to])) {
// Only attach a CSS class, then get out // Only attach a CSS class, then get out

View File

@ -154,8 +154,7 @@ release.
* **Attachments**: you can now copy & paste, or drag & drop files (images, PDF, * **Attachments**: you can now copy & paste, or drag & drop files (images, PDF,
whatever you like) into a page and it will be uploaded and appropriately whatever you like) into a page and it will be uploaded and appropriately
linked from your page. Attachment size is currently limited to 100mb. linked from your page. Attachment size is currently limited to 100mb. Changed full-text search page prefix from `@search/` to `🔍` for the {[Search
* Changed full-text search page prefix from `@search/` to `🔍` for the {[Search
Space]} command. Space]} command.
* `page`, `plug` and `attachment` are now _reserved page names_, you cannot name * `page`, `plug` and `attachment` are now _reserved page names_, you cannot name
your pages these (you will get an error when explicitly navigating to them). your pages these (you will get an error when explicitly navigating to them).