Community maintained Docker config for the knot server

Add Spindle container image build #12

open opened by psychedeli.ca targeting main from psychedeli.ca/knot-docker: spindle

This PR adds tngl/spindle as a new image, using the same Dockerfile as the Knot server but in an additional stage of the build. By building the images from the same Dockerfile, we can re-use the clone from a single tag and cache more artifacts between builds. It also introduces a docker bake workflow and a docker-bake.hcl file to describe images built off the master branch and given the :edge tag (which is an emerging convention in container tag nomenclature).

The build succeeded, but I got a bunch of warnings about inconsistent case (my editor was yelling at me when it encountered lowercase Dockerfile instructions):

 24 warnings found (use docker --debug to expand):
 - ConsistentInstructionCasing: Command 'CMD' should match the case of the command majority (lowercase) (line 66)
 - ConsistentInstructionCasing: Command 'FROM' should match the case of the command majority (lowercase) (line 10)
 - ConsistentInstructionCasing: Command 'FROM' should match the case of the command majority (lowercase) (line 13)
 - ConsistentInstructionCasing: Command 'ARG' should match the case of the command majority (lowercase) (line 57)
 - ConsistentInstructionCasing: Command 'COPY' should match the case of the command majority (lowercase) (line 63)
 - FromAsCasing: 'AS' and 'from' keywords' casing do not match (line 16)
 - ConsistentInstructionCasing: Command 'RUN' should match the case of the command majority (lowercase) (line 11)
 - ConsistentInstructionCasing: Command 'LABEL' should match the case of the command majority (lowercase) (line 49)
 - ConsistentInstructionCasing: Command 'LABEL' should match the case of the command majority (lowercase) (line 52)
 - ConsistentInstructionCasing: Command 'LABEL' should match the case of the command majority (lowercase) (line 53)
 - ConsistentInstructionCasing: Command 'RUN' should match the case of the command majority (lowercase) (line 61)
 - ConsistentInstructionCasing: Command 'WORKDIR' should match the case of the command majority (lowercase) (line 65)
 - ConsistentInstructionCasing: Command 'RUN' should match the case of the command majority (lowercase) (line 14)
 - ConsistentInstructionCasing: Command 'FROM' should match the case of the command majority (lowercase) (line 46)
 - ConsistentInstructionCasing: Command 'EXPOSE' should match the case of the command majority (lowercase) (line 47)
 - ConsistentInstructionCasing: Command 'LABEL' should match the case of the command majority (lowercase) (line 50)
 - ConsistentInstructionCasing: Command 'ARG' should match the case of the command majority (lowercase) (line 56)
 - ConsistentInstructionCasing: Command 'RUN' should match the case of the command majority (lowercase) (line 59)
 - ConsistentInstructionCasing: Command 'VOLUME' should match the case of the command majority (lowercase) (line 67)
 - ConsistentInstructionCasing: Command 'HEALTHCHECK' should match the case of the command majority (lowercase) (line 68)
 - ConsistentInstructionCasing: Command 'ENV' should match the case of the command majority (lowercase) (line 17)
 - ConsistentInstructionCasing: Command 'LABEL' should match the case of the command majority (lowercase) (line 51)
 - ConsistentInstructionCasing: Command 'LABEL' should match the case of the command majority (lowercase) (line 54)
 - ConsistentInstructionCasing: Command 'RUN' should match the case of the command majority (lowercase) (line 60)

...so I was wondering if I could commit this other change that formats the Dockerfile properly? But I figured I'd let y'all see the changes first before they're obfuscated by all that reformatting.

Labels

None yet.

Participants 3
AT URI
at://did:plc:cmla2he5nqvubofxm4pzgtyi/sh.tangled.repo.pull/3m6bb2zk52i22
+50 -13
Interdiff #0 β†’ #1
Dockerfile

This file has not been changed.

+30
docker-bake.hcl
··· 1 + variable "UID" { 2 + default = "1000" 3 + } 4 + 5 + variable "GID" { 6 + default = "1000" 7 + } 8 + 1 9 group "edge" { 2 10 targets = ["knot-edge", "spindle-edge"] 3 11 } 4 12 5 13 target "knot-edge" { 6 14 context = "." 15 + target = "knot" 7 16 args = { 8 17 TAG = "master" 18 + UID = UID 19 + GID = GID 9 20 } 10 21 tags = ["tngl/knot:edge"] 11 22 } 12 23 13 24 target "spindle-edge" { 14 25 context = "." 26 + target = "spindle" 15 27 args = { 16 28 TAG = "master" 29 + UID = UID 30 + GID = GID 17 31 } 18 32 tags = ["tngl/spindle:edge"] 19 33 } 34 + 35 + target "all" { 36 + name = "${APP}-${replace(TAG, ".", "-")}" 37 + context = "." 38 + matrix = { 39 + APP = ["knot", "spindle"] 40 + TAG = ["v1.11.0-alpha", "v1.10.0-alpha", "v1.9.0-alpha", "v1.8.0-alpha"] 41 + } 42 + target = "${APP}" 43 + args = { 44 + TAG = "${TAG}" 45 + UID = UID 46 + GID = GID 47 + } 48 + tags = ["tngl/${APP}:${TAG}"] 49 + }
+4 -7
docker-compose.yml
··· 4 4 image: tngl/knot:latest 5 5 build: 6 6 target: knot 7 - args: 8 - UID: 1000 9 - GID: 1000 7 + args: &args 8 + UID: ${UID:-1000} 9 + GID: ${GID:-1000} 10 10 TAG: ${TAG:-v1.11.0-alpha} 11 11 tags: 12 12 - tngl/spindle:latest ··· 29 29 image: tngl/spindle:latest 30 30 build: 31 31 target: spindle 32 - args: 33 - UID: 1000 34 - GID: 1000 35 - TAG: ${TAG:-v1.11.0-alpha} 32 + args: *args 36 33 tags: 37 34 - tngl/spindle:latest 38 35 - tngl/spindle:${TAG:-v1.11.0-alpha}
+16 -6
readme.md
··· 36 36 docker bake spindle 37 37 ``` 38 38 39 - By default the `Dockerfile` will build the latest tag, but you can change it 40 - with the `TAG` build argument. 39 + By default this will build the latest tag, but you can target a specific tag 40 + like so: 41 41 42 42 ```sh 43 - docker bake --build-arg TAG=v1.10.0-alpha 43 + docker bake knot-v1-10-0-alpha spindle-v1-10-0-alpha 44 44 ``` 45 45 46 - The command above for example will build the `v1.10.0-alpha` tag. 46 + The 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 48 + also optionally specify just one to build at a specific version. 49 + 50 + You can also build all tagged releases: 51 + 52 + ```sh 53 + docker bake all 54 + ``` 47 55 48 56 By default it will also create a `git` / `spindle` user with user and group ID 1000:1000, 49 57 but you can change it with the `UID` and `GID` build arguments. 50 58 51 59 ```sh 52 - docker bake --build-arg UID=$(id -u) --build-arg GID=$(id -g) 60 + docker bake UID=$(id -u) GID=$(id -g) 53 61 ``` 54 62 55 63 The command above for example will create a user with the host user's UID and GID. ··· 62 70 63 71 ```sh 64 72 docker bake edge 65 - # or, with a specific target image 73 + # 74 + # or, with a specific target image... 75 + # 66 76 docker bake edge-knot 67 77 docker bake edge-spindle 68 78 ```

History

3 rounds 4 comments
sign up or login to add to the discussion
8 commits
expand
add build stage for the spindle server
add spindle to docker-compose and configure builds for each image
add docker bake config for building edge releases
update readme to reference the spindle and document how to build images using docker bake
fix adduser/group commands in spindle stage
add legacy releases task and info on how to build past releases
rename releases to all
add docs around variables
merge conflicts detected
expand
  • Dockerfile:1
expand 0 comments
8 commits
expand
add build stage for the spindle server
bump tag to v1.11.0 in Dockerfile
add spindle to docker-compose and configure builds for each image
add docker bake config for building edge releases
update readme to reference the spindle and document how to build images using docker bake
fix adduser/group commands in spindle stage
add legacy releases task and info on how to build past releases
rename releases to all
expand 4 comments

Why not simply using a very simple Dockerfile, like this one for instance: https://tangled.org/strings/julien.rbrt.fr/3m75vdbmdad22

It's unclear to me why this would be built into the knot docker repo. Not all knot hosters will want to host spindles.

@julien.rbrt.fr all the dependencies and build commands are the same between the two tangled components so sharing their stages between builds makes building both of those programs faster.

@knotbin.com do you feel like the spindle image would be better off built in a different repo? my only reason for PRing here is so both the knot & spindle builds could take advantage of some dependency and artifact caching due to the multi-stage dockerfile. but if it’s better off in a different repo that’s fine too.

i concur, I think this should be fine to merge once conflicts are fixed.

6 commits
expand
add build stage for the spindle server
bump tag to v1.11.0 in Dockerfile
add spindle to docker-compose and configure builds for each image
add docker bake config for building edge releases
update readme to reference the spindle and document how to build images using docker bake
fix adduser/group commands in spindle stage
expand 0 comments