Skip to content

Commit 7f76cc4

Browse files
committed
Use docker buildx
1 parent 3732758 commit 7f76cc4

File tree

3 files changed

+50
-23
lines changed

3 files changed

+50
-23
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@ jobs:
55
build:
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: actions/checkout@v3
8+
- name: Checkout repository
9+
uses: actions/checkout@v3
10+
# https://github.com/docker/setup-qemu-action
11+
- name: Set up QEMU
12+
uses: docker/setup-qemu-action@v1
13+
# https://github.com/docker/setup-buildx-action
14+
- name: Set up Docker Buildx
15+
uses: docker/setup-buildx-action@v1
916
- name: Build image
1017
run: make docker-build
18+
env:
19+
DOCKER_BUILDKIT: 1
1120
- name: Test image
1221
run: make test

.github/workflows/publish.yml

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
name: Publish Docker image
22
on:
3-
release:
4-
types: [published]
3+
release:
4+
types: [published]
55

66
jobs:
7-
push_to_registry:
8-
name: Push Docker image to GitHub Packages
9-
runs-on: ubuntu-latest
10-
steps:
11-
- name: Check out the repo
12-
uses: actions/checkout@v3
13-
- name: Login to GitHub registry
14-
uses: docker/login-action@v1
15-
with:
16-
registry: ghcr.io
17-
username: ${{ github.repository_owner }}
18-
password: ${{ secrets.GITHUB_TOKEN }}
7+
push_to_registry:
8+
name: Push Docker image to GitHub Packages
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out the repo
12+
uses: actions/checkout@v3
13+
# https://github.com/docker/setup-qemu-action
14+
- name: Set up QEMU
15+
uses: docker/setup-qemu-action@v1
16+
# https://github.com/docker/setup-buildx-action
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v1
19+
- name: Login to GitHub registry
20+
uses: docker/login-action@v1
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.repository_owner }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
1925

20-
- name: Build image
21-
run: IMAGE_TAG="ghcr.io/sudo-bot/docker-phpldapadmin/docker-phpldapadmin" make docker-build
26+
- name: Build image
27+
run: IMAGE_TAG="ghcr.io/sudo-bot/docker-phpldapadmin/docker-phpldapadmin" make docker-build
28+
env:
29+
DOCKER_BUILDKIT: 1
2230

23-
- name: Test image
24-
run: IMAGE_TAG="ghcr.io/sudo-bot/docker-phpldapadmin/docker-phpldapadmin" make docker-test
31+
- name: Test image
32+
run: IMAGE_TAG="ghcr.io/sudo-bot/docker-phpldapadmin/docker-phpldapadmin" make docker-test
2533

26-
- name: Push to GitHub Packages
27-
run: docker push ghcr.io/sudo-bot/docker-phpldapadmin/docker-phpldapadmin:latest
34+
- name: Push to GitHub Packages
35+
run: docker push ghcr.io/sudo-bot/docker-phpldapadmin/docker-phpldapadmin:latest

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
IMAGE_TAG ?= docker-phpldapadmin
22
TEST_ADDR ?= phpldapadmin
3+
# All: linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6
4+
PLATFORM ?= linux/amd64
5+
6+
ACTION ?= load
7+
PROGRESS_MODE ?= plain
38

49
.PHONY: docker-build docker-test run-test cleanup-test test
510

611
all: docker-build docker-test
712

813
docker-build:
9-
docker build ./docker \
14+
# https://github.com/docker/buildx#building
15+
docker buildx build \
1016
--build-arg VCS_REF=`git rev-parse HEAD` \
1117
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
1218
--build-arg RUST_PYTHON_VERSION=`docker run -q --rm dclong/rustpython:alpine --version | cut -d ' ' -f 2` \
1319
--tag $(IMAGE_TAG) \
14-
--pull
20+
--progress $(PROGRESS_MODE) \
21+
--platform $(PLATFORM) \
22+
--pull \
23+
--$(ACTION) \
24+
./docker
1525

1626
docker-test: test
1727

0 commit comments

Comments
 (0)