feat: tag image version on build + start (#36)

This commit is contained in:
Marc 2023-12-15 23:56:22 -05:00 committed by GitHub
commit 53d9690876
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 30 additions and 14 deletions

View file

@ -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-<commit-hash>`).

View file

@ -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 }}

View file

@ -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:

View file

@ -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 .

View file

@ -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

View file

@ -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 .

View file

@ -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

View file

@ -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 .

View file

@ -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

View file

@ -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 .

View file

@ -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

View file

@ -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 .

View file

@ -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