Community maintained Docker config for the knot server
at spindle 111 lines 2.9 kB view raw view rendered
1# Knot Docker 2 3> **IMPORTANT** 4> This is a community maintained repository, support is not guaranteed. 5 6Docker container and compose setup to run a [Tangled](https://tangled.org) knot 7and spindle, hosting your own repository data and CI. 8 9## Pre-built Images 10 11There is a [repository](https://hub.docker.com/r/tngl) of pre-built images 12for tags starting at `v1.8.0-alpha` if you prefer. 13 14```sh 15docker pull tngl/knot:v1.10.0-alpha 16docker pull tngl/spindle:v1.10.0-alpha 17``` 18 19Note that these are *not* official images, you use them at your own risk. 20 21## Building The Images 22 23Both the knot and spindle images are built using the same `Dockerfile`, since 24they're sourced from the same codebase and can therefore share a lot of the 25build steps (such as `go mod download`), caching results between them. You 26can build the images locally by running `docker bake`: 27 28```sh 29docker bake 30``` 31 32Optionally, choose a target image to build: 33 34```sh 35docker bake knot 36docker bake spindle 37``` 38 39By default this will build the latest tag, but you can target a specific tag 40like so: 41 42```sh 43docker bake knot-v1-10-0-alpha spindle-v1-10-0-alpha 44``` 45 46The command above for example will build the `v1.10.0-alpha` tag for both the 47`knot` and `spindle`. They're expressed as individual bake targets, so you can 48also optionally specify just one to build at a specific version. 49 50You can also build all tagged releases: 51 52```sh 53docker bake all 54``` 55 56By default it will also create a `git` / `spindle` user with user and group ID 1000:1000, 57but you can change it with the `UID` and `GID` build arguments. 58 59```sh 60docker bake UID=$(id -u) GID=$(id -g) 61``` 62 63The command above for example will create a user with the host user's UID and GID. 64This is useful if you are bind mounting the repositories and app folder on the host, 65as in the provided `docker-compose.yml` file. 66 67You can also build the latest commit on `master` for both services by using 68the `-edge` targets. These will build to a tag named `:edge` to distinguish 69it from the `:latest` release: 70 71```sh 72docker bake edge 73# 74# or, with a specific target image... 75# 76docker bake edge-knot 77docker bake edge-spindle 78``` 79 80<hr style="margin-bottom: 20px; margin-top: 10px" /> 81 82When using compose, these can be specified as build arguments which will be 83passed to the builder. 84 85```yaml 86build: 87 context: . 88 args: 89 TAG: master 90 UID: 1000 91 GID: 1000 92``` 93 94This will for example tell docker to build it using the `master` branch like 95the command. 96 97## Setting Up The Image 98 99The simplest way to set up your own knot and spindle is to use the provided 100compose file and run the following: 101 102```sh 103export KNOT_SERVER_HOSTNAME="knot.example.com" 104export SPINDLE_SERVER_HOSTNAME="spindle.example.com" 105export KNOT_SERVER_OWNER="did:plc:yourdidgoeshere" 106export KNOT_SERVER_PORT="443" 107 108docker compose up --detach 109``` 110 111This will setup everything for you including a reverse proxy.