mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-01-08 10:45:04 +02:00
Multiarch build with Google Cloud Build
This commit is contained in:
parent
cc40caf53f
commit
f442403c25
56
cloudbuild.yaml
Normal file
56
cloudbuild.yaml
Normal file
@ -0,0 +1,56 @@
|
||||
steps:
|
||||
- id: 'docker_amd64'
|
||||
name: 'docker'
|
||||
entrypoint: 'sh'
|
||||
args:
|
||||
- '-c'
|
||||
- |
|
||||
docker build \
|
||||
-t darthsim/imgproxy:$TAG_NAME-amd64 \
|
||||
-f docker/Dockerfile \
|
||||
--build-arg TARGET_ARCH="amd64" \
|
||||
.
|
||||
env:
|
||||
- DOCKER_BUILDKIT=1
|
||||
waitFor: ["-"]
|
||||
|
||||
- id: 'docker_arm64'
|
||||
name: 'docker'
|
||||
entrypoint: 'sh'
|
||||
args:
|
||||
- '-c'
|
||||
- |
|
||||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes \
|
||||
&& docker build \
|
||||
-t darthsim/imgproxy:$TAG_NAME-arm64 \
|
||||
-f docker/Dockerfile \
|
||||
--platform=arm64 \
|
||||
--build-arg TARGET_ARCH="arm64" \
|
||||
.
|
||||
env:
|
||||
- DOCKER_BUILDKIT=1
|
||||
waitFor: ["-"]
|
||||
|
||||
- id: 'push'
|
||||
name: 'docker'
|
||||
entrypoint: 'sh'
|
||||
args:
|
||||
- '-c'
|
||||
- |
|
||||
apk add --no-cache bash \
|
||||
&& docker login -u darthsim -p $$DOCKER_HUB_TOKEN \
|
||||
&& docker/push-images.sh ${TAG_NAME}
|
||||
secretEnv: ['DOCKER_HUB_TOKEN']
|
||||
waitFor: ['docker_amd64', 'docker_arm64']
|
||||
|
||||
|
||||
availableSecrets:
|
||||
secretManager:
|
||||
- versionName: projects/${PROJECT_ID}/secrets/DOCKER_HUB_TOKEN/versions/latest
|
||||
env: DOCKER_HUB_TOKEN
|
||||
|
||||
options:
|
||||
machineType: 'N1_HIGHCPU_8'
|
||||
dynamic_substitutions: true
|
||||
|
||||
timeout: 1200s
|
@ -1,15 +1,15 @@
|
||||
ARG BASE_IMAGE_VERSION="v3.0.1"
|
||||
ARG BASE_IMAGE_VERSION="v3.1.0"
|
||||
ARG TARGET_ARCH="amd64"
|
||||
|
||||
FROM darthsim/imgproxy-base:${BASE_IMAGE_VERSION}
|
||||
LABEL maintainer="Sergey Alexandrovich <darthsim@gmail.com>"
|
||||
FROM --platform=${TARGET_ARCH} darthsim/imgproxy-base:${BASE_IMAGE_VERSION}
|
||||
|
||||
COPY . .
|
||||
RUN go build -v -o /usr/local/bin/imgproxy
|
||||
RUN ["bash", "-c", "go build -v -o /usr/local/bin/imgproxy"]
|
||||
|
||||
# ==================================================================================================
|
||||
# Final image
|
||||
|
||||
FROM debian:bullseye-slim
|
||||
FROM --platform=${TARGET_ARCH} debian:bullseye-slim
|
||||
LABEL maintainer="Sergey Alexandrovich <darthsim@gmail.com>"
|
||||
|
||||
RUN apt-get update \
|
||||
|
@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
re="^v([0-9]+)\.([0-9]+)\.([0-9]+)$"
|
||||
|
||||
if [[ $DOCKER_TAG =~ $re ]]; then
|
||||
docker tag $IMAGE_NAME "$DOCKER_REPO:v${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
|
||||
docker push "$DOCKER_REPO:v${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
|
||||
|
||||
docker tag $IMAGE_NAME "$DOCKER_REPO:v${BASH_REMATCH[1]}"
|
||||
docker push "$DOCKER_REPO:v${BASH_REMATCH[1]}"
|
||||
fi
|
34
docker/push-images.sh
Executable file
34
docker/push-images.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
TAG_NAME=${1:-latest}
|
||||
REPO_NAME="darthsim/imgproxy"
|
||||
|
||||
IMAGE_NAME="$REPO_NAME:$TAG_NAME"
|
||||
|
||||
echo "Image name: $IMAGE_NAME"
|
||||
|
||||
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||
|
||||
docker push $IMAGE_NAME-amd64
|
||||
docker push $IMAGE_NAME-arm64
|
||||
|
||||
push_manifest() {
|
||||
docker manifest create $1 -a $2-amd64 -a $2-arm64
|
||||
docker manifest annotate $1 $2-amd64 --arch amd64
|
||||
docker manifest annotate $1 $2-arm64 --arch arm64 --variant v8
|
||||
docker manifest push $1
|
||||
}
|
||||
|
||||
push_manifest $IMAGE_NAME $IMAGE_NAME
|
||||
|
||||
re="^v([0-9]+)\.([0-9]+)\.([0-9]+)$"
|
||||
|
||||
if [[ $TAG_NAME =~ $re ]]; then
|
||||
MINOR_IMAGE_NAME="$REPO_NAME:v${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
|
||||
push_manifest $MINOR_IMAGE_NAME $IMAGE_NAME
|
||||
|
||||
MAJOR_IMAGE_NAME="$REPO_NAME:v${BASH_REMATCH[1]}"
|
||||
push_manifest $MAJOR_IMAGE_NAME $IMAGE_NAME
|
||||
fi
|
Loading…
Reference in New Issue
Block a user