Browse Source
The bitwarden_rs code is still cross-compiled exactly as before, but Docker Buildx is used to rewrite the resulting Docker images with correct platform metadata (reflecting the target platform instead of the build platform). Buildx also now handles building and pushing the multi-arch manifest lists.pull/1304/head
11 changed files with 181 additions and 112 deletions
@ -0,0 +1,33 @@ |
|||||
|
# The cross-built images have the build arch (`amd64`) embedded in the image |
||||
|
# manifest, rather than the target arch. For example: |
||||
|
# |
||||
|
# $ docker inspect bitwardenrs/server:latest-armv7 | jq -r '.[]|.Architecture' |
||||
|
# amd64 |
||||
|
# |
||||
|
# Recent versions of Docker have started printing a warning when the image's |
||||
|
# claimed arch doesn't match the host arch. For example: |
||||
|
# |
||||
|
# WARNING: The requested image's platform (linux/amd64) does not match the |
||||
|
# detected host platform (linux/arm/v7) and no specific platform was requested |
||||
|
# |
||||
|
# The image still works fine, but the spurious warning creates confusion. |
||||
|
# |
||||
|
# Docker doesn't seem to provide a way to directly set the arch of an image |
||||
|
# at build time. To resolve the build vs. target arch discrepancy, we use |
||||
|
# Docker Buildx to build a new set of images with the correct target arch. |
||||
|
# |
||||
|
# Docker Buildx uses this Dockerfile to build an image for each requested |
||||
|
# platform. Since the Dockerfile basically consists of a single `FROM` |
||||
|
# instruction, we're effectively telling Buildx to build a platform-specific |
||||
|
# image by simply copying the existing cross-built image and setting the |
||||
|
# correct target arch as a side effect. |
||||
|
# |
||||
|
# References: |
||||
|
# |
||||
|
# - https://docs.docker.com/buildx/working-with-buildx/#build-multi-platform-images |
||||
|
# - https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope |
||||
|
# - https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact |
||||
|
# |
||||
|
ARG LOCAL_REPO |
||||
|
ARG DOCKER_TAG |
||||
|
FROM ${LOCAL_REPO}:${DOCKER_TAG}-${TARGETARCH}${TARGETVARIANT} |
@ -1,19 +1,16 @@ |
|||||
# The default Debian-based images support these arches for all database connections |
# The default Debian-based images support these arches for all database backends. |
||||
# |
|
||||
# Other images (Alpine-based) currently |
|
||||
# support only a subset of these. |
|
||||
arches=( |
arches=( |
||||
amd64 |
amd64 |
||||
arm32v6 |
armv6 |
||||
arm32v7 |
armv7 |
||||
arm64v8 |
arm64 |
||||
) |
) |
||||
|
|
||||
if [[ "${DOCKER_TAG}" == *alpine ]]; then |
if [[ "${DOCKER_TAG}" == *alpine ]]; then |
||||
# The Alpine build currently only works for amd64. |
# The Alpine image build currently only works for certain arches. |
||||
os_suffix=.alpine |
distro_suffix=.alpine |
||||
arches=( |
arches=( |
||||
amd64 |
amd64 |
||||
arm32v7 |
armv7 |
||||
) |
) |
||||
fi |
fi |
||||
|
@ -0,0 +1,18 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
set -ex |
||||
|
|
||||
|
# Print some environment info in case it's useful for troubleshooting. |
||||
|
id |
||||
|
pwd |
||||
|
df -h |
||||
|
env |
||||
|
docker info |
||||
|
docker version |
||||
|
|
||||
|
# Install build dependencies. |
||||
|
deps=( |
||||
|
jq |
||||
|
) |
||||
|
apt-get update |
||||
|
apt-get install -y "${deps[@]}" |
Loading…
Reference in new issue