Skip to content

Commit

Permalink
refactor(images): dry and update info on how to publish
Browse files Browse the repository at this point in the history
  • Loading branch information
hugotiburtino committed Nov 12, 2024
1 parent 394502e commit cbdd0e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,5 @@ Docker and Make

### Building and pushing images

After changing a specific image, you should build and push it manually.
Example:

1. `cd images/dbdump`
2. Change the version in `images/dbdump/Makefile`
3. Be sure you have already authenticated with [docker to Github Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-with-a-personal-access-token-classic)
4. `make docker_build_push`

If you want to test the image just locally, use `make docker_build` in the 3rd step.
If you want to test the image just locally, use `make docker_build`.
To publish an image just push to any branch after changing a version, and the CI is gone take care of it.
12 changes: 2 additions & 10 deletions images/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,13 @@ patch_version ?= $(shell git log --pretty=format:'' | wc -l)

.PHONY: docker_build
docker_build:
docker build --build-arg version=$(version) --build-arg git_revision=$(shell git log | head -n 1 | cut -f 2 -d ' ') -t $(image_name):$(version) -t $(image_name):latest .
docker build --build-arg version=$(version) --build-arg git_revision=$(shell git log | head -n 1 | cut -f 2 -d ' ') -t $(image_name):$(version) .

.PHONY: docker_build_push
docker_build_push:
docker pull $(remote_image_name):$(version) 2>/dev/null >/dev/null || $(MAKE) docker_build docker_push

.PHONY: docker_push
docker_push:
docker tag $(image_name):latest $(remote_image_name):latest
docker push $(remote_image_name):latest
docker tag $(image_name):latest $(remote_image_name):$(major_version)
docker push $(remote_image_name):$(major_version)
docker tag $(image_name):latest $(remote_image_name):$(major_version).$(minor_version)
docker push $(remote_image_name):$(major_version).$(minor_version)
docker tag $(image_name):latest $(remote_image_name):$(version)
docker tag $(image_name):$(version) $(remote_image_name):$(version)
docker push $(remote_image_name):$(version)
docker tag $(image_name):latest $(remote_image_name):sha-$(shell git describe --dirty --always)
docker push $(remote_image_name):sha-$(shell git describe --dirty --always)

0 comments on commit cbdd0e1

Please sign in to comment.