pg_tileserv icon indicating copy to clipboard operation
pg_tileserv copied to clipboard

Working proof-of-concept for a multi-architecture Docker image build

Open vicchi opened this issue 2 years ago • 4 comments

Self contained POC for a full multi-architecture Docker image build for the following architectures:

  • linux/386
  • linux/amd64
  • linux/arm/v6
  • linux/arm/v7
  • linux/arm64

The current, tested, build is available here: https://github.com/vicchi/pg_tileserv/pkgs/container/pg_tileserv. This image was built and tested on an AMD Ryzen 9 5900X running Ubuntu 22.04 and then tested on an Intel Core i7-8700K, also running Ubuntu 22.04, a Raspberry Pi 4 Model B, a Raspberry Pi 3 Model B and a MacBook Pro with an M1 Pro running macOS 14.2.1 Sonoma.

This isn't production ready inasmuch as it's not integrated into the current Makefile or Dockerfile/Dockerfile.alpine nor is it integrated in the Actions CI pipeline. Instead I've isolated this in Makefile.multiarch and Dockerfile.multiarch for comment and review. I'm more than happy to re-issue this PR with all of this merged into the current build pipeline if it passes muster.

Currently the build is configured by a .env (see .env.sample for a template) containing the PAT, GitHub user and Registry URL and requires Docker buildx to be pre-installed, which should be the case with the latest Docker version (24.0.7 according to my main build server).

Key build targets are:

  • build - spins up a buildx builder and then builds for all configured architectures, pushes to the container repo and tags as latest
  • rebuild - as for build but ignores the build cache
  • release - tags the image in the container repo with the commit hash at HEAD and the current released version (read from ./VERSION)
  • lint - uses hadolint/hadolint to sanity check the Dockerfile.multiarch

There's several previous requests for this sort of image build as well as one which looks to have been merged and subsequently backed out; see #69, #72, #127 for context and history.

vicchi avatar Jan 07 '24 13:01 vicchi

@crunchyheath can you review and make sure we can use these builds and still get the right images we need off the repo?

pramsey avatar Jan 07 '24 18:01 pramsey

@vicchi I appreciate this PR! We (crunchy) have some internal requirements for our build and handling of container making, so we are attacking this slightly differently, and we'd be interested in hearing your feedback on https://github.com/CrunchyData/pg_featureserv/pull/154 to make sure that all your requirements are met by the reworking too.

pramsey avatar Jan 14 '24 18:01 pramsey

@pramsey Just taken a look at https://github.com/CrunchyData/pg_featureserv/pull/154 and it's definitely a different approach but all I can really add is it looks good (and will also be a good source of reference for what I assume it a CI based image build).

My requirements are pretty basic; currently I take the pg_tileserv image, wrap it in a custom Dockerfile to add a health check and that derived image is then spun up as multiple tile servers via Docker compose; one per PostgreSQL/PostGIS environment in RDS.

Deployment wise, all our "servers" are X86_64 EC2 instance but my team run on macOS and I'm trialling being able to allow them to deploy our full container stack on their local machines, hence the multi-architecture approach in this PR.

As long as I can pull down a container that supports Intel/AMD and Apple Silicon/ARM then I'm happy 😄

vicchi avatar Jan 14 '24 21:01 vicchi

As long as I can pull down a container that supports Intel/AMD and Apple Silicon/ARM then I'm happy

Do you know if ARM64 meets that bar or do the specific Apple variants need targets?

pramsey avatar Jan 18 '24 19:01 pramsey