Skip to content

Commit

Permalink
allow multiple tags (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
nstoik committed Apr 9, 2024
1 parent 64c9430 commit af8746c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -19,7 +19,7 @@ Here we write upgrading notes for.

## Unreleased - [v0.3.4](https://github.com/nstoik/farm_device/releases/tag/v0.3.4) - 2024-mm-dd

Update the `TAG` variable in the `.env` file to `v0.3.4`. Then execute the following to pull and run the containers:
Update the `FD_TAG` variable in the `.env` file to `v0.3.4`. Then execute the following to pull and run the containers:
```bash
> docker compose -f docker-compose.yml -f docker-compose.prod.yml --env-file .env -p fd_prod down
> docker compose -f docker-compose.yml -f docker-compose.prod.yml --env-file .env -p fd_prod pull
Expand All @@ -28,6 +28,7 @@ Update the `TAG` variable in the `.env` file to `v0.3.4`. Then execute the follo

### Added
- `CHANGELOG.md` file to track changes to the project and added documentation on how to release new versions.
- Docker buildx bake file can now accept a comma separated list of tags to apply to containters

### Changed
- SQLAlchemy relations. Changed `backref` to `back_populates`.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -177,21 +177,21 @@ To list the available builders run:
docker buildx ls
```

Bake all the containers. In the example below, the TAG variable is set to the tag you want to build.
Bake all the containers. In the example below, the TAGS variable is set to the tag (or comma seperated string of multiple tags) you want to build.
```bash
TAG=0.1 docker buildx bake --builder fd_buildx --file docker-bake.hcl --push
TAGS=0.1 docker buildx bake --builder fd_buildx --file docker-bake.hcl --push
```

To bake a single target or group specified in the `docker-bake.hcl` configuration file, run the following, replacing "TARGET_NAME" with the target or group name:
```bash
TAG=0.1 docker buildx bake --builder fd_buildx --file docker-bake.hcl --push "TARGET_NAME"
TAGS=0.1 docker buildx bake --builder fd_buildx --file docker-bake.hcl --push "TARGET_NAME"
```


**Note** Overwrite variables defined in the `docker-bake.hcl` file by specifying them as arguments to the command. Any required `ARG` in the docker files need to be specified in the `docker-bake.hcl` file.

The list of available variables are:
- TAG: The tag of the docker image to build. Defaults to "dev"
- TAGS: The tag of the docker image to build. Defaults to "dev". Can be a comma separated list of tags to apply multiple tags eg. "dev,latest".
- MULTI_STAGE_TARGET: The target to build. Defaults to "prod-stage"

A few additional comments on the `docker-bake.hcl` file:
Expand Down
9 changes: 4 additions & 5 deletions docker-bake.hcl
@@ -1,4 +1,4 @@
variable "TAG" {
variable "TAGS" {
default = "dev"
}
variable "MULTI_STAGE_TARGET" {
Expand All @@ -11,20 +11,19 @@ group "default" {

target "default" {
platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7"]
context = "."
pull = true
}

target "fd_device" {
inherits = ["default"]
context = "."
dockerfile = "device/Dockerfile"
tags = ["nstoik/fd_device:${TAG}"]
tags = [for tag in split(",", "${TAGS}") : "nstoik/fd_device:${tag}"]
target = "${MULTI_STAGE_TARGET}"
}

target "fd_1wire" {
inherits = ["default"]
context = "."
dockerfile = "1wire/Dockerfile"
tags = ["nstoik/fd_1wire:${TAG}"]
tags = [for tag in split(",", "${TAGS}") : "nstoik/fd_1wire:${tag}"]
}

0 comments on commit af8746c

Please sign in to comment.