Skip to content

Commit fd6e4c1

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

7 files changed

Lines changed: 120 additions & 73 deletions

File tree

‎.github/workflows/main.yml‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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@v4
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: Run build
26+
run: |
27+
make build push

‎.github/workflows/pull-request.yml‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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
36+
build-args: BUILDKIT_INLINE_CACHE=1

‎.github/workflows/testing.yml‎

Lines changed: 0 additions & 27 deletions
This file was deleted.

‎Makefile‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
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
611
.PHONY: help
712
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

15+
.PHONY: pull
16+
pull: ## pull docker build cache from registry
17+
@docker pull $(CACHE_IMG)
18+
19+
20+
.PHONY: build
21+
build: ## build image using buildx
22+
cd compose && docker buildx build \
23+
--cache-from type=registry,ref=ghcr.io/adfinis/pyaptly/cache:latest \
24+
--build-arg BUILDKIT_INLINE_CACHE=1 \
25+
-t ghcr.io/adfinis/pyaptly/cache:latest .
26+
27+
1028
.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
29+
up: build ## start the container (cached)
30+
@docker compose up -d
1431

1532
.PHONY: push
1633
push: ## push docker build cache to registry
17-
@docker push ghcr.io/adfinis/pyaptly/cache:latest
34+
@docker push $(CACHE_IMG)
1835

1936
.PHONY: down
2037
down: ## stop and remove container

‎compose/Dockerfile‎

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
1-
ARG DOCKER_IMAGE
2-
FROM $DOCKER_IMAGE
1+
FROM debian:bookworm-slim
32

4-
RUN apt-get update && apt-get install -y --no-install-recommends \
5-
python3-toml \
6-
python3-requests \
7-
python3-poetry \
8-
gnupg \
9-
bzip2 \
10-
tini \
11-
curl \
12-
wait-for-it \
13-
entr \
14-
gnutls-bin \
15-
nettle-dev \
16-
gcc \
17-
llvm-dev \
18-
libclang-dev \
19-
build-essential \
20-
pkg-config \
21-
gettext \
22-
git \
23-
procps \
24-
psmisc \
25-
vim-tiny \
26-
cargo \
27-
&& rm -rf /var/lib/apt/lists/* \
28-
&& apt-get clean \
29-
&& apt-get autoclean \
30-
&& rm -rf /var/lib/apt/archives/* \
31-
&& rm -rf /var/cache/apt/*
32-
ADD setup /setup
33-
RUN /setup/setup
3+
#RUN apt-get update && apt-get install -y --no-install-recommends \
4+
# python3-toml \
5+
# python3-requests \
6+
# python3-poetry \
7+
# gnupg \
8+
# bzip2 \
9+
# tini \
10+
# curl \
11+
# wait-for-it \
12+
# entr \
13+
# gnutls-bin \
14+
# nettle-dev \
15+
# gcc \
16+
# llvm-dev \
17+
# libclang-dev \
18+
# build-essential \
19+
# pkg-config \
20+
# gettext \
21+
# git \
22+
# procps \
23+
# psmisc \
24+
# vim-tiny \
25+
# cargo \
26+
# && rm -rf /var/lib/apt/lists/* \
27+
# && apt-get clean \
28+
# && apt-get autoclean \
29+
# && rm -rf /var/lib/apt/archives/* \
30+
# && rm -rf /var/cache/apt/*
31+
# ADD setup /setup
32+
# RUN echo build build build build
33+
# RUN /setup/setup
3434
ADD run /setup/run
35-
ENTRYPOINT ["/usr/bin/tini", "--"]
35+
#WORKDIR /source
36+
#ENTRYPOINT ["/usr/bin/tini", "--"]
37+
#CMD ["bash", "/setup/run"]

‎compose/setup/version‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2

‎docker-compose.yml‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,5 @@
22
services:
33
testing:
44
image: ghcr.io/adfinis/pyaptly/cache:latest
5-
build:
6-
cache_from:
7-
- ghcr.io/adfinis/pyaptly/cache:latest
8-
context: compose
9-
args:
10-
BUILDKIT_INLINE_CACHE: 1
11-
DOCKER_IMAGE: debian:bookworm-slim
12-
working_dir: /source
13-
command: ["bash", "/setup/run"]
145
volumes:
156
- ./:/source

0 commit comments

Comments
 (0)