Skip to content

Commit

Permalink
chore: Update docker-compose.yml to use BUILD_TAG for image tags
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricdcc committed May 24, 2024
1 parent b4d2c21 commit d62c0d1
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .env.dist
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
TAG_VERSION=
BUILD_TAG=
REG_NS= #ghcr.io/vlizbe/vocabserver-app
9 changes: 1 addition & 8 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,4 @@ jobs:
fi
echo $BUILD_TAG
DIMGS="content-unification vocab-configs vocab-fetch"
cd services
for dimg in $DIMGS; do
echo "Building $REG_NS/$dimg:$BUILD_TAG"
docker build -t $REG_NS/$dimg:$BUILD_TAG -f $dimg/Dockerfile .
docker push $REG_NS/$dimg:$BUILD_TAG
done
make docker-push
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ x-logging: &default-logging
max-file: "3"
services:
frontend:
image: ghcr.io/vlizbe/vocabserver-frontend:${TAG_VERSION}
image: ghcr.io/vlizbe/vocabserver-frontend:${BUILD_TAG}
restart: always
logging: *default-logging
identifier:
Expand Down Expand Up @@ -113,7 +113,7 @@ services:
vocab-fetch:
build:
context: ./services/vocab-fetch
image: ghcr.io/vlizbe/vocabserver-app/vocab-fetch:${TAG_VERSION}
image: ${REG_NS:-vocabserver_app}/vocab-fetch:${BUILD_TAG}
volumes:
- ./data/vocab-fetch:/share
# Run in dev mode to circument memory limitations
Expand All @@ -126,7 +126,7 @@ services:
content-unification:
build:
context: ./services/content-unification
image: ghcr.io/vlizbe/vocabserver-app/content-unification:${TAG_VERSION:-latest}
image: ${REG_NS:-vocabserver_app}/content-unification:${BUILD_TAG:-latest}
volumes:
- ./data/vocab-fetch:/share
environment:
Expand All @@ -144,7 +144,7 @@ services:
restart: always
logging: *default-logging
webcomponent:
image: ghcr.io/vlizbe/vocabserver-webcomponent:${TAG_VERSION:-latest}
image: ghcr.io/vlizbe/vocabserver-webcomponent:${BUILD_TAG:-latest}
ldes-consumer-manager:
image: redpencil/ldes-consumer-manager:0.1.0
environment:
Expand All @@ -157,7 +157,7 @@ services:
vocab-configs:
build:
context: ./services/vocab-configs
image: ghcr.io/vlizbe/vocabserver-app/vocab-configs:${TAG_VERSION:-latest}
image: ${REG_NS:-vocabserver_app}/vocab-configs:${BUILD_TAG:-latest}
environment:
MU_APPLICATION_FILE_STORAGE_PATH: "vocab-configs/"
MODE: "development"
Expand Down
54 changes: 54 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Note: Ensure variable declarations in makefiles have NO trailing whitespace
# This can be achieved by sliding in the # comment-sign directly after the value

include .env

PROJECT := "vocabserver-app"# - this project
TIME_TAG := $(shell date +%s)# - the unix epoch
BUILD_TAG ?= ${TIME_TAG}# - provide the BUILD_TAG in the environment, or fallback to time
REG_NS ?= "vocabserver-app"# - allow the namespace to be overridden to e.g. ghcr.io/vlizbe/vocabserver-app
DIMGS="content-unification vocab-configs vocab-fetch"# - the list of docker images in docker-compose.yml ready to be pushed

.PHONY: help docker-build docker-push docker-start docker-stop
.DEFAULT_GOAL := help


help: ## Shows this list of available targets and their effect.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'


# usage `make BUILD_TAG=0.2 docker-build` to include a specific tag to the build docker images
docker-build: ## Builds the docker-images as described in the local docker-compose.yml for ${REG_NS} and ${BUILD_TAG}
@echo "building all images as described in local docker-compose.yml for registry/namespace=${REG_NS} with tag=${BUILD_TAG}"
@env BUILD_TAG=${BUILD_TAG} REG_NS=${REG_NS} bash -c "docker compose build --no-cache"


# usage `make REG_NS=ghcr.io/vliz-be-opsci/kgap docker-build` to push images to github-container-registry
docker-push: docker-build ## Builds, then pushes the docker-images to ${REG_NS}
@echo "pushing docker images tagged=${BUILD_TAG} to registry/namespace=${REG_NS}"
ifeq ($(shell echo ${REG_NS} | egrep '.+/.+'),) # the 'shell' call is essential
# empty match indicates no registry-part is available to push to
@echo "not pushing docker images if no / between non-empty parts in REG_NS=${REG_NS}"
@exit 1
else
# note the double $$ on dn distinction between makefile and shell var expansion
@for dn in "${DIMGS}"; do \
docker push ${REG_NS}/${PROJECT}_$${dn}:${BUILD_TAG}; \
done;
endif


docker-start: ## Launches local-named variants of the containers/images in docker-compose.yml
@echo "launching docker-stack for local test with default names and tags"
@mkdir -p ./data/
@mkdir -p ./notebooks/
@docker compose -p ${PROJECT} up -d


docker-stop: ## Stops local-named variants of those containers
@echo "shutting down docker-stack from docker-start"
@docker compose -p ${PROJECT} down


docker-clean: ## Helps (interactively) to cleanup containers and images linked to this project
@./docker_clean.sh ${PROJECT}

0 comments on commit d62c0d1

Please sign in to comment.