Skip to content

Commit 7a15909

Browse files
author
Jean-Louis Fuchs
committed
use buildx/inline cache
1 parent a45c18c commit 7a15909

File tree

6 files changed

+85
-38
lines changed

6 files changed

+85
-38
lines changed

.github/workflows/main.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
schedule:
8+
- cron: "0 0 * * 0"
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
18+
- name: Login to GitHub Container Registry
19+
uses: docker/login-action@v3
20+
with:
21+
registry: ghcr.io
22+
username: ${{ github.actor }}
23+
password: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
with:
28+
buildkitd-flags: --debug
29+
30+
- name: Build container
31+
uses: docker/build-push-action@v5
32+
with:
33+
context: compose
34+
push: true
35+
tags: ghcr.io/adfinis/pyaptly/cache:latest
36+
cache-from: type=gha
37+
cache-to: type=gha,mode=max

.github/workflows/pull-request.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Login to GitHub Container Registry
17+
uses: docker/login-action@v3
18+
with:
19+
registry: ghcr.io
20+
username: ${{ github.actor }}
21+
password: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
with:
26+
buildkitd-flags: --debug
27+
28+
- name: Build container
29+
uses: docker/build-push-action@v5
30+
with:
31+
context: compose
32+
push: false
33+
tags: ghcr.io/adfinis/pyaptly/cache:latest
34+
cache-from: type=gha
35+
cache-to: type=gha,mode=max

.github/workflows/testing.yml

-27
This file was deleted.

Makefile

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
.DEFAULT_GOAL := help
22

3+
CACHE_IMG = "ghcr.io/adfinis/pyaptly/cache:latest"
4+
5+
DOCKER_BUILDKIT = 1
6+
export DOCKER_BUILDKIT
7+
38
# Help target extracts the double-hash comments from the targets and shows them
49
# in a convenient way. This allows us to easily document the user-facing Make
510
# targets
@@ -8,13 +13,12 @@ help:
813
@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}'
914

1015
.PHONY: up
11-
up: ## start and build container if needed
12-
#@docker pull ghcr.io/adfinis/pyaptly/cache:latest
13-
@DOCKER_BUILDKIT=1 docker compose up -d --build
16+
up: ## start the container (cached)
17+
@docker compose up -d --build
1418

1519
.PHONY: push
1620
push: ## push docker build cache to registry
17-
@docker push ghcr.io/adfinis/pyaptly/cache:latest
21+
@docker push $(CACHE_IMG)
1822

1923
.PHONY: down
2024
down: ## stop and remove container

compose/Dockerfile

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
ARG DOCKER_IMAGE
2-
FROM $DOCKER_IMAGE
1+
FROM debian:bookworm-slim
32

43
RUN apt-get update && apt-get install -y --no-install-recommends \
54
python3-toml \
@@ -32,4 +31,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
3231
ADD setup /setup
3332
RUN /setup/setup
3433
ADD run /setup/run
35-
ENTRYPOINT ["/usr/bin/tini", "--"]
34+
WORKDIR /source
35+
ENTRYPOINT ["/usr/bin/tini", "--"]
36+
CMD ["bash", "/setup/run"]

docker-compose.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ services:
44
image: ghcr.io/adfinis/pyaptly/cache:latest
55
build:
66
cache_from:
7-
- ghcr.io/adfinis/pyaptly/cache:latest
7+
- type=registry,ref=ghcr.io/adfinis/pyaptly/cache:latest
88
context: compose
99
args:
1010
BUILDKIT_INLINE_CACHE: 1
11-
DOCKER_IMAGE: debian:bookworm-slim
12-
working_dir: /source
13-
command: ["bash", "/setup/run"]
1411
volumes:
1512
- ./:/source

0 commit comments

Comments
 (0)