Skip to content
This repository has been archived by the owner on Aug 27, 2023. It is now read-only.

Add multi-arch support to build.sh #37

Merged
merged 2 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI
on:
release:
types: [released, prereleased]
workflow_dispatch: # allow manually running from the Actions tab
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stevearc fwiw you as maintainer can trigger the flow manually for any branch from the Actions tab.

did the acript fail locally or in CI?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it wants an older version of psycopg-binary, which did not have aarch64_manylinux2014 wheels available yet 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correction: just saw psycopg2-binary, with the 2. none of those have arm wheels available ;( solutions would be to add support for v3 (maybe no breaking changes that hit us), or prepare the dockerfile so the v2 install from source will succeed

Copy link
Contributor Author

@ddelange ddelange Aug 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could try adding the apt package libpq-dev and see if source install in the arm image starts working

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an alternative: https://github.com/docker/setup-buildx-action/blob/master/README.md#max-parallelism

although no space left can probably be avoided 'properly' as this should not be a heavy build

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like most of the builds finish pretty quickly; it's just alpine linux on arm64 that's heavy. Kind of expected, since you can't use most binary packages and instead have to compile almost everything yourself https://github.com/stevearc/pypicloud-docker/runs/8039880052

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes, alpine... always a pain especially for python projects 😅 we once tried it at work cuz of 'smaller images' fetish, ended up quickly reverting to debian slim

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally managed to build and release 1.3.9 images! I ended up disabling the arm build on alpine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoop whoop!! 🎉 thanks so much for your perseverance 🙏


jobs:
build:
runs-on: ubuntu-latest
env:
BUILDX_PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this env var can be customised also in local env: all available archs will be printed by QEMU setup

steps:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
Comment on lines +18 to +19
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two you would have to add to https://github.com/stevearc/pypicloud-docker/settings/secrets/actions

which is safe as only you can trigger this workflow

- run: bash build.sh
ddelange marked this conversation as resolved.
Show resolved Hide resolved
16 changes: 9 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ set -e -o pipefail

./cp-static.sh
tag=$(git describe --tags)
echo "Building $tag"
platforms=${BUILDX_PLATFORMS:-linux/amd64}
alias buildx_build="docker buildx build --platform=${platforms}"
echo "Building ${tag} for platforms ${platforms}"

docker build --pull py3-baseimage -t "stevearc/pypicloud:latest" -t "stevearc/pypicloud:$tag"
docker build --pull py3-alpine -t "stevearc/pypicloud:latest-alpine" -t "stevearc/pypicloud:$tag-alpine"
buildx_build --pull py3-baseimage -t "stevearc/pypicloud:latest"
buildx_build --pull py3-alpine -t "stevearc/pypicloud:latest-alpine"

if [ "$1" == '--publish' ]; then
if [ -n "$(git status --porcelain)" ]; then
Expand All @@ -19,11 +21,11 @@ if [ "$1" == '--publish' ]; then
./test.sh latest
./test.sh latest-alpine
echo "Tests passed"
docker push "stevearc/pypicloud:latest"
docker push "stevearc/pypicloud:latest-alpine"
buildx_build --push py3-baseimage -t "stevearc/pypicloud:latest"
buildx_build --push py3-alpine -t "stevearc/pypicloud:latest-alpine"
if git describe --tags --exact-match; then
docker push "stevearc/pypicloud:$tag"
docker push "stevearc/pypicloud:$tag-alpine"
buildx_build --push py3-baseimage -t "stevearc/pypicloud:$tag"
buildx_build --push py3-alpine -t "stevearc/pypicloud:$tag-alpine"
else
echo "Not pushing $tag because it is not an exact version"
fi
Expand Down