From 4719a9d64c7d641d3e69ff5caadee97192ecf643 Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Fri, 15 Dec 2023 23:51:38 -0500 Subject: [PATCH 1/2] feat(taskfiles): expose current version based on latest release or dev tag --- Taskfile.internal.yml | 4 ++++ Taskfile.yml | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/Taskfile.internal.yml b/Taskfile.internal.yml index a063027..ab6a809 100644 --- a/Taskfile.internal.yml +++ b/Taskfile.internal.yml @@ -8,10 +8,14 @@ tasks: prefix: "build image: {{ .SERVICE }}" dir: services/{{ .SERVICE }} cmd: . ./build.sh + env: + IMAGE_VERSION: "{{ .VERSION }}" start-service: prefix: "start: {{ .SERVICE }}" dir: services/{{ .SERVICE }} cmd: . ./start.sh + env: + IMAGE_VERSION: "{{ .VERSION }}" stop-service: prefix: "stop: {{ .SERVICE }}" dir: services/{{ .SERVICE }} diff --git a/Taskfile.yml b/Taskfile.yml index 05895f0..678a709 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -11,6 +11,11 @@ includes: output: prefixed +vars: + # Any build that is not on a tag is a development build. + CURRENT_VERSION: + sh: git describe --tags --exact-match $(git rev-parse HEAD) 2> /dev/null || echo "dev-$(git rev-parse HEAD)" + tasks: build: desc: "Builds images for one or more services. Include service names as a space-separated list." @@ -19,6 +24,7 @@ tasks: task: internal:build-images vars: SERVICE: "{{ .ITEM }}" + VERSION: "{{ .CURRENT_VERSION }}" prefix: "build: {{ .CLI_ARGS }}" dir: services start: @@ -28,6 +34,7 @@ tasks: task: internal:start-service vars: SERVICE: "{{ .ITEM }}" + VERSION: "{{ .CURRENT_VERSION }}" prefix: "start: {{ .CLI_ARGS }}" dir: services stop: From e0a20dbe91c4829b1a868373a795f641ffd56785 Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Fri, 15 Dec 2023 23:52:03 -0500 Subject: [PATCH 2/2] feat: update all services to tag images with release or dev+hash docs: mention version-tagging --- README.md | 5 +++++ services/bastion/build.sh | 2 +- services/bastion/start.sh | 2 +- services/bitwarden/build.sh | 4 ++-- services/bitwarden/start.sh | 4 ++-- services/bookstack/build.sh | 4 ++-- services/bookstack/start.sh | 4 ++-- services/deluge/build.sh | 2 +- services/deluge/start.sh | 2 +- services/plex/build.sh | 2 +- services/plex/start.sh | 2 +- 11 files changed, 19 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 0452ce6..93d73da 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,8 @@ env: ``` The `env.yml` file is ignored by version-control. + +### Image versions + +When building and starting images, images are tagged with either the release version (if on a commit that's tagged with +a release) or a dev tag that includes the hash (i.e. `dev-`). diff --git a/services/bastion/build.sh b/services/bastion/build.sh index c1c8dbc..0123c23 100644 --- a/services/bastion/build.sh +++ b/services/bastion/build.sh @@ -2,4 +2,4 @@ source constants.sh -docker build -t $APP_IMAGE_NAME:dev -f Dockerfile-bastion-app . +docker build -t $APP_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-bastion-app . diff --git a/services/bastion/start.sh b/services/bastion/start.sh index 9127429..2d8f247 100644 --- a/services/bastion/start.sh +++ b/services/bastion/start.sh @@ -9,4 +9,4 @@ docker run \ --network $NETWORK_NAME \ --name $APP_CONTAINER_NAME \ --env-file $ENV_FILE_DIR/bastion.env \ - $APP_IMAGE_NAME:dev + $APP_IMAGE_NAME:$IMAGE_VERSION diff --git a/services/bitwarden/build.sh b/services/bitwarden/build.sh index 59dd88f..de4d126 100644 --- a/services/bitwarden/build.sh +++ b/services/bitwarden/build.sh @@ -2,5 +2,5 @@ source constants.sh -docker build -t $DB_IMAGE_NAME:dev -f Dockerfile-bitwarden-db . -docker build -t $APP_IMAGE_NAME:dev -f Dockerfile-bitwarden-app . +docker build -t $DB_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-bitwarden-db . +docker build -t $APP_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-bitwarden-app . diff --git a/services/bitwarden/start.sh b/services/bitwarden/start.sh index a281880..a904191 100644 --- a/services/bitwarden/start.sh +++ b/services/bitwarden/start.sh @@ -10,7 +10,7 @@ docker run \ --name $DB_CONTAINER_NAME \ --env-file $ENV_FILE_DIR/bitwarden-db.env \ --mount type=bind,source=$APP_DATA_DIR/bitwarden/db,target=/var/lib/mysql \ - $DB_IMAGE_NAME:dev + $DB_IMAGE_NAME:$IMAGE_VERSION docker run \ --detach \ @@ -20,4 +20,4 @@ docker run \ --publish 8080:8080 \ --mount type=bind,source=$APP_DATA_DIR/bitwarden/config,target=/etc/bitwarden \ --mount type=bind,source=$APP_DATA_DIR/bitwarden/logs,target=/var/log/bitwarden \ - $APP_IMAGE_NAME:dev + $APP_IMAGE_NAME:$IMAGE_VERSION diff --git a/services/bookstack/build.sh b/services/bookstack/build.sh index d56d161..c53c7c9 100644 --- a/services/bookstack/build.sh +++ b/services/bookstack/build.sh @@ -2,5 +2,5 @@ source constants.sh -docker build -t $DB_IMAGE_NAME:dev -f Dockerfile-bookstack-db . -docker build -t $APP_IMAGE_NAME:dev -f Dockerfile-bookstack-app . +docker build -t $DB_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-bookstack-db . +docker build -t $APP_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-bookstack-app . diff --git a/services/bookstack/start.sh b/services/bookstack/start.sh index e8bda88..86ebdd7 100644 --- a/services/bookstack/start.sh +++ b/services/bookstack/start.sh @@ -10,7 +10,7 @@ docker run \ --name $DB_CONTAINER_NAME \ --env-file $ENV_FILE_DIR/bookstack-db.env \ --mount type=bind,source=$APP_DATA_DIR/bookstack-db,target=/var/lib/mysql \ - $DB_IMAGE_NAME:dev + $DB_IMAGE_NAME:$IMAGE_VERSION docker run \ --detach \ @@ -19,4 +19,4 @@ docker run \ --env-file $ENV_FILE_DIR/bookstack-app.env \ --publish 6875:80 \ --mount type=bind,source=$APP_DATA_DIR/bookstack-app,target=/config \ - $APP_IMAGE_NAME:dev + $APP_IMAGE_NAME:$IMAGE_VERSION diff --git a/services/deluge/build.sh b/services/deluge/build.sh index d2adb1b..0560945 100644 --- a/services/deluge/build.sh +++ b/services/deluge/build.sh @@ -2,4 +2,4 @@ source constants.sh -docker build -t $APP_IMAGE_NAME:dev -f Dockerfile-deluge-app . +docker build -t $APP_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-deluge-app . diff --git a/services/deluge/start.sh b/services/deluge/start.sh index 69b05e6..facfdea 100644 --- a/services/deluge/start.sh +++ b/services/deluge/start.sh @@ -15,4 +15,4 @@ docker run \ --mount type=bind,source=$APP_DATA_DIR/deluge/config,target=/config \ --mount type=bind,source=$APP_DATA_DIR/deluge/downloads,target=/downloads \ --mount type=bind,source=$STORAGE_DIR,target=/complete \ - $APP_IMAGE_NAME:dev + $APP_IMAGE_NAME:$IMAGE_VERSION diff --git a/services/plex/build.sh b/services/plex/build.sh index 27a376f..5e39262 100644 --- a/services/plex/build.sh +++ b/services/plex/build.sh @@ -2,4 +2,4 @@ source constants.sh -docker build -t $APP_IMAGE_NAME:dev -f Dockerfile-plex-app . +docker build -t $APP_IMAGE_NAME:$IMAGE_VERSION -f Dockerfile-plex-app . diff --git a/services/plex/start.sh b/services/plex/start.sh index f84ee09..a623874 100644 --- a/services/plex/start.sh +++ b/services/plex/start.sh @@ -21,4 +21,4 @@ docker run \ --mount type=bind,source=$APP_DATA_DIR/plex/database,target=/config \ --mount type=bind,source=$APP_DATA_DIR/plex/transcode,target=/transcode \ --mount type=bind,source=$STORAGE_DIR/media,target=/data \ - $APP_IMAGE_NAME:dev + $APP_IMAGE_NAME:$IMAGE_VERSION