From 4b9e2fd6c1e11c6171b4a907e89807c16b9c5737 Mon Sep 17 00:00:00 2001 From: Nicco Kunzmann Date: Wed, 5 Feb 2025 15:37:58 +0000 Subject: [PATCH 1/4] Create first draft of multiplatform build --- .github/workflows/main.yml | 1 + Makefile | 11 +++++++++-- README.md | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2617f7342..9c49bddc7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,6 +32,7 @@ jobs: env: VERSION: ${{ matrix.postgres }}-${{ matrix.postgis }} VARIANT: ${{ matrix.variant }} + PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7,linux/386 steps: - name: Checkout source diff --git a/Makefile b/Makefile index cb6f6abba..a81371644 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,13 @@ IMAGE_NAME ?= postgis DOCKER=docker DOCKERHUB_DESC_IMG=peterevans/dockerhub-description:latest +# choice between buildx and build depending on the PLATFORMS variable +ifdef PLATFORMS + BUILD := buildx build --platform $(PLATFORMS) +else + BUILD := build +endif + GIT=git OFFIMG_LOCAL_CLONE=$(HOME)/official-images OFFIMG_REPO_URL=https://github.com/docker-library/official-images.git @@ -76,12 +83,12 @@ update: define build-version build-$1: ifeq ($(do_default),true) - $(DOCKER) build --pull -t $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1) $1 + $(DOCKER) $(BUILD) --pull -t $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1) $1 $(DOCKER) images $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1) endif ifeq ($(do_alpine),true) ifneq ("$(wildcard $1/alpine)","") - $(DOCKER) build --pull -t $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1)-alpine $1/alpine + $(DOCKER) $(BUILD) --pull -t $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1)-alpine $1/alpine $(DOCKER) images $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1)-alpine endif endif diff --git a/README.md b/README.md index 5211685ba..a06ff3f28 100644 --- a/README.md +++ b/README.md @@ -193,6 +193,21 @@ This Docker-PostGIS project [is part of the PostGIS group](https://postgis.net/d * If you have a major change in mind, we kindly ask you to start a discussion about it first. * After making changes to the templates, please run the `./update.sh` script. +## Building Docker Images + +To build the all Docker images on your local machine, run: + +```sh +make build +``` + +To build for a different platform, install `docker buildx` and run: + +```sh +export PLATFORMS="linux/arm64,linux/amd64" +make build +``` + ## Code of Conduct see: https://postgis.net/community/conduct/ From 5bb1ff1f7aa1741fed65534a32eccdf8f14c12d0 Mon Sep 17 00:00:00 2001 From: Nicco Kunzmann Date: Wed, 5 Feb 2025 15:42:30 +0000 Subject: [PATCH 2/4] Add buildx install to github actions --- .github/workflows/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9c49bddc7..a931870fe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,6 +38,12 @@ jobs: - name: Checkout source uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build docker image for ${{ env.VERSION }} ${{ env.VARIANT }} run: make test From c91da6dd013a86db4da1e77d6ae175dd7c437fff Mon Sep 17 00:00:00 2001 From: Nicco Kunzmann Date: Thu, 6 Feb 2025 14:23:10 +0000 Subject: [PATCH 3/4] Remove modification to docker build action --- .github/workflows/main.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a931870fe..2617f7342 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,18 +32,11 @@ jobs: env: VERSION: ${{ matrix.postgres }}-${{ matrix.postgis }} VARIANT: ${{ matrix.variant }} - PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7,linux/386 steps: - name: Checkout source uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Build docker image for ${{ env.VERSION }} ${{ env.VARIANT }} run: make test From e4f8728dd15913fb0afe75706c7ce7d52896f4b7 Mon Sep 17 00:00:00 2001 From: Phillip Ross Date: Sat, 21 Jun 2025 18:58:50 -0400 Subject: [PATCH 4/4] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use build command instead of explicit buildx command Co-authored-by: Máté Gyöngyösi --- Makefile | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index a81371644..cb6f6abba 100644 --- a/Makefile +++ b/Makefile @@ -58,13 +58,6 @@ IMAGE_NAME ?= postgis DOCKER=docker DOCKERHUB_DESC_IMG=peterevans/dockerhub-description:latest -# choice between buildx and build depending on the PLATFORMS variable -ifdef PLATFORMS - BUILD := buildx build --platform $(PLATFORMS) -else - BUILD := build -endif - GIT=git OFFIMG_LOCAL_CLONE=$(HOME)/official-images OFFIMG_REPO_URL=https://github.com/docker-library/official-images.git @@ -83,12 +76,12 @@ update: define build-version build-$1: ifeq ($(do_default),true) - $(DOCKER) $(BUILD) --pull -t $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1) $1 + $(DOCKER) build --pull -t $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1) $1 $(DOCKER) images $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1) endif ifeq ($(do_alpine),true) ifneq ("$(wildcard $1/alpine)","") - $(DOCKER) $(BUILD) --pull -t $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1)-alpine $1/alpine + $(DOCKER) build --pull -t $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1)-alpine $1/alpine $(DOCKER) images $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1)-alpine endif endif