Is there an automated way to tag Docker images inside Compose based on Git version?

Viewed 314

I have a CI process (based on a compose file) that builds the docker images every night.

I'd like the image to get a TAG based on GIT automatically.

I work with .env files, and I'd like to put a bash command there, say:

TAG=$(git rev-list --all --count).$(git rev-list HEAD --count)

and then in docker-compose.yml:

 web:
    image: docker-registry/myapp/web:${TAG}
    build:
      context: ./web

I know I can pass arguments e.g.:

TAG=$(git rev-list --all --count) docker build . -t web:$TAG

but I have about 10 images so I have to use a compose file.

Is there any way to do this?

0 Answers
Related