feat(deployment): add QEMU setup for cross-platform builds and improve Docker Buildx configuration
Deploy production / deploy (push) Has been cancelled
Deploy production / deploy (push) Has been cancelled
This commit is contained in:
@@ -16,6 +16,12 @@ jobs:
|
||||
uses: https://github.com/actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up QEMU for cross-platform builds
|
||||
uses: https://github.com/docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: amd64,arm64
|
||||
# Gitea does not use the GitHub Actions cache backend.
|
||||
cache-image: false
|
||||
- name: Build and push to Gitea Packages
|
||||
shell: bash
|
||||
env:
|
||||
@@ -31,14 +37,31 @@ jobs:
|
||||
: "${REGISTRY_PASSWORD:?Set REGISTRY_PASSWORD}"
|
||||
registry="${IMAGE_PREFIX%%/*}"
|
||||
auth_dir=$(mktemp -d)
|
||||
trap 'rm -rf -- "$auth_dir"' EXIT
|
||||
builder_name=""
|
||||
cleanup() {
|
||||
local rc=$?
|
||||
if [[ -n "$builder_name" ]]; then
|
||||
docker buildx rm "$builder_name" >/dev/null || true
|
||||
fi
|
||||
rm -rf -- "$auth_dir"
|
||||
exit "$rc"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
trap 'exit 130' INT
|
||||
trap 'exit 143' TERM
|
||||
export DOCKER_CONFIG="$auth_dir"
|
||||
export BUILDX_CONFIG="$auth_dir/buildx"
|
||||
printf '%s' "$REGISTRY_PASSWORD" | docker login "$registry" --username "$REGISTRY_USERNAME" --password-stdin
|
||||
unset REGISTRY_PASSWORD
|
||||
docker build --pull --load --platform "${BUILD_PLATFORM:-linux/amd64}" \
|
||||
# Create after selecting the isolated config; do not change the runner's default builder.
|
||||
builder_name=$(docker buildx create --driver docker-container)
|
||||
docker info --format 'Build host: {{.OSType}}/{{.Architecture}}'
|
||||
echo "Target platform: ${BUILD_PLATFORM:-linux/amd64}"
|
||||
docker buildx inspect "$builder_name" --bootstrap
|
||||
docker buildx build --builder "$builder_name" --pull --load --platform "${BUILD_PLATFORM:-linux/amd64}" \
|
||||
--label "org.opencontainers.image.revision=$DEPLOY_TAG" \
|
||||
-f Dockerfile.backend -t "$IMAGE_PREFIX-backend:$DEPLOY_TAG" .
|
||||
docker build --pull --load --platform "${BUILD_PLATFORM:-linux/amd64}" \
|
||||
docker buildx build --builder "$builder_name" --pull --load --platform "${BUILD_PLATFORM:-linux/amd64}" \
|
||||
--label "org.opencontainers.image.revision=$DEPLOY_TAG" \
|
||||
-f Dockerfile.frontend -t "$IMAGE_PREFIX-web:$DEPLOY_TAG" .
|
||||
docker push "$IMAGE_PREFIX-backend:$DEPLOY_TAG"
|
||||
|
||||
Reference in New Issue
Block a user