Skip to content

Commit

Permalink
use buildx/inline cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Louis Fuchs committed Dec 25, 2023
1 parent a45c18c commit fbf2938
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,21 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Run build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
uses: docker/build-push-action@v5
with:
context: compose
push: false
tags: ghcr.io/adfinis/pyaptly/cache:latest
cache-from: type=registry,ref=ghcr.io/adfinis/pyaptly/cache:latest
cache-to: type=inline

- name: Start container
run: |
make up push
make up
- name: Run tests
run: |
Expand Down
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
.DEFAULT_GOAL := help

CACHE_IMG = "ghcr.io/adfinis/pyaptly/cache:latest"

DOCKER_BUILDKIT = 1
export DOCKER_BUILDKIT

# 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
Expand All @@ -8,13 +13,12 @@ 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: 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: ## start the container (cached)
@docker compose up -d --build

.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
Expand Down
7 changes: 4 additions & 3 deletions compose/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down Expand Up @@ -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", "--"]
WORKDIR /source
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["bash", "/setup/run"]
5 changes: 1 addition & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ services:
image: ghcr.io/adfinis/pyaptly/cache:latest
build:
cache_from:
- ghcr.io/adfinis/pyaptly/cache:latest
- type=registry,ref=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

0 comments on commit fbf2938

Please sign in to comment.