mirror of
https://github.com/imgproxy/imgproxy.git
synced 2024-11-18 16:31:44 +02:00
Use native Go in Docker build
This commit is contained in:
parent
fe145def64
commit
7e3b838c45
@ -5,7 +5,6 @@ tmp/
|
||||
imgproxy
|
||||
|
||||
docs/
|
||||
docker/
|
||||
examples/
|
||||
LICENSE
|
||||
README.md
|
||||
|
@ -2,8 +2,11 @@ ARG BASE_IMAGE_VERSION="v3.2.1"
|
||||
|
||||
FROM darthsim/imgproxy-base:${BASE_IMAGE_VERSION}
|
||||
|
||||
ARG BUILDPLATFORM
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
COPY . .
|
||||
RUN ["bash", "-c", "go build -v -o /usr/local/bin/imgproxy"]
|
||||
RUN docker/go.sh build -v -o /usr/local/bin/imgproxy
|
||||
|
||||
# ==================================================================================================
|
||||
# Final image
|
||||
|
52
docker/go.sh
Executable file
52
docker/go.sh
Executable file
@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# This is pretty dirty hack. Building imgproxy under Qemu is pretty slow.
|
||||
# So we install Go binary native for the BUILDPLATFORM.
|
||||
if [[ $BUILDPLATFORM != $TARGETPLATFORM ]]; then
|
||||
case "$BUILDPLATFORM" in
|
||||
amd64 | "linux/amd64")
|
||||
BUILD_ARCH="amd64"
|
||||
;;
|
||||
|
||||
arm64 | "arm64/v8" | "linux/arm64" | "linux/arm64/v8")
|
||||
BUILDPLATFORM="arm64"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown platform: $BUILDPLATFORM"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
case "$TARGETPLATFORM" in
|
||||
amd64 | "linux/amd64")
|
||||
TARGET_ARCH="amd64"
|
||||
;;
|
||||
|
||||
arm64 | "arm64/v8" | "linux/arm64" | "linux/arm64/v8")
|
||||
TARGET_ARCH="arm64"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown platform: $TARGETPLATFORM"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
GOLANG_VERSION=$(go version | sed -E 's/.*go([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
|
||||
|
||||
rm -rf /usr/local/go
|
||||
|
||||
dpkg --add-architecture ${BUILD_ARCH}
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends libstdc++6:${BUILD_ARCH}
|
||||
|
||||
curl -Ls https://golang.org/dl/go${GOLANG_VERSION}.linux-${BUILD_ARCH}.tar.gz \
|
||||
| tar -xzC /usr/local
|
||||
|
||||
export CGO_ENABLED=1
|
||||
export GOOS=linux
|
||||
export GOARCH=$TARGET_ARCH
|
||||
fi
|
||||
|
||||
go $@
|
Loading…
Reference in New Issue
Block a user