From 32c8e4531c6e4d978ded507683f6604fbaf3bf3a Mon Sep 17 00:00:00 2001 From: Jean-Louis Fuchs Date: Mon, 25 Dec 2023 11:09:37 +0100 Subject: [PATCH] use buildx/cache --- .github/workflows/testing.yml | 2 +- Makefile | 14 ++++++++++---- compose/Dockerfile | 7 ++++--- docker-compose.yml | 9 --------- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index e6e1f33..8ecfc02 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -20,7 +20,7 @@ jobs: - name: Run build run: | - make up push + make up - name: Run tests run: | diff --git a/Makefile b/Makefile index 592979c..4eeb8c0 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ .DEFAULT_GOAL := help +CACHE_IMG = "ghcr.io/adfinis/pyaptly/cache:latest" + # Help target extracts the double-hash comments from the targets and shows them # in a convenient way. This allows us to easily document the user-facing Make # targets @@ -7,14 +9,18 @@ help: @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort -k 1,1 | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' +.PHONY: pull +pull: ## pull cached container + @docker pull $(CACHE_IMG) + .PHONY: up -up: ## start and build container if needed - #@docker pull ghcr.io/adfinis/pyaptly/cache:latest - @DOCKER_BUILDKIT=1 docker compose up -d --build +up: pull ## start and build container if needed + @docker buildx build --cache-from $(CACHE_IMG) -t $(CACHE_IMG) compose + @docker compose up -d .PHONY: push push: ## push docker build cache to registry - @docker push ghcr.io/adfinis/pyaptly/cache:latest + @docker push $(CACHE_IMG) .PHONY: down down: ## stop and remove container diff --git a/compose/Dockerfile b/compose/Dockerfile index 9b20f4d..bf18a8d 100644 --- a/compose/Dockerfile +++ b/compose/Dockerfile @@ -1,5 +1,4 @@ -ARG DOCKER_IMAGE -FROM $DOCKER_IMAGE +FROM debian:bookworm-slim RUN apt-get update && apt-get install -y --no-install-recommends \ python3-toml \ @@ -32,4 +31,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ADD setup /setup RUN /setup/setup ADD run /setup/run -ENTRYPOINT ["/usr/bin/tini", "--"] \ No newline at end of file +WORKDIR /source +ENTRYPOINT ["/usr/bin/tini", "--"] +CMD ["bash", "/setup/run"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index e90c033..72fe5cf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,14 +2,5 @@ services: testing: image: ghcr.io/adfinis/pyaptly/cache:latest - build: - cache_from: - - ghcr.io/adfinis/pyaptly/cache:latest - context: compose - args: - BUILDKIT_INLINE_CACHE: 1 - DOCKER_IMAGE: debian:bookworm-slim - working_dir: /source - command: ["bash", "/setup/run"] volumes: - ./:/source