mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-09-30 14:06:48 +02:00
Another try to fix crossbuild of Docker images
This commit is contained in:
@@ -1,12 +1,27 @@
|
||||
ARG BASE_IMAGE_VERSION="v3.10.0"
|
||||
|
||||
FROM darthsim/imgproxy-base:${BASE_IMAGE_VERSION}
|
||||
FROM --platform=${BUILDPLATFORM} darthsim/imgproxy-base:${BASE_IMAGE_VERSION} as base-native
|
||||
|
||||
FROM darthsim/imgproxy-base:${BASE_IMAGE_VERSION} as build
|
||||
|
||||
ARG TARGETARCH
|
||||
ARG BUILDARCH
|
||||
ARG TARGETARCH
|
||||
|
||||
RUN dpkg --add-architecture ${BUILDARCH} \
|
||||
&& apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libstdc++6:${BUILDARCH}
|
||||
|
||||
# This is pretty dirty hack. Building imgproxy under Qemu is pretty slow.
|
||||
# So we install Go binary native for the BUILDARCH.
|
||||
RUN rm -rf /usr/local/go
|
||||
COPY --from=base-native /usr/local/go /usr/local/go
|
||||
|
||||
ENV CGO_ENABLED=1
|
||||
ENV GOOS=linux
|
||||
ENV GOARCH=$TARGETARCH
|
||||
|
||||
COPY . .
|
||||
RUN docker/build.sh
|
||||
RUN bash -c 'go build -v -ldflags "-s -w" -o /usr/local/bin/imgproxy'
|
||||
|
||||
# ==================================================================================================
|
||||
# Final image
|
||||
@@ -31,8 +46,8 @@ RUN apt-get update \
|
||||
&& ln -s /usr/lib/$(uname -m)-linux-gnu/libtcmalloc_minimal.so.4 /usr/local/lib/libtcmalloc_minimal.so \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=0 /usr/local/bin/imgproxy /usr/local/bin/
|
||||
COPY --from=0 /usr/local/lib /usr/local/lib
|
||||
COPY --from=build /usr/local/bin/imgproxy /usr/local/bin/
|
||||
COPY --from=build /usr/local/lib /usr/local/lib
|
||||
|
||||
COPY docker/entrypoint.sh /usr/local/bin/
|
||||
|
||||
|
@@ -1,24 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# This is pretty dirty hack. Building imgproxy under Qemu is pretty slow.
|
||||
# So we install Go binary native for the BUILDARCH.
|
||||
if [[ $BUILDARCH != $TARGETARCH ]]; then
|
||||
GOLANG_VERSION=$(go version | sed -E 's/.*go([0-9]+\.[0-9]+(\.[0-9]+)?).*/\1/')
|
||||
|
||||
rm -rf /usr/local/go
|
||||
|
||||
dpkg --add-architecture ${BUILDARCH}
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends libstdc++6:${BUILDARCH}
|
||||
|
||||
curl -Ls https://golang.org/dl/go${GOLANG_VERSION}.linux-${BUILDARCH}.tar.gz \
|
||||
| tar -xzC /usr/local
|
||||
|
||||
export CGO_ENABLED=1
|
||||
export GOOS=linux
|
||||
export GOARCH=$TARGETARCH
|
||||
fi
|
||||
|
||||
go build -v -ldflags "-s -w" -o /usr/local/bin/imgproxy
|
Reference in New Issue
Block a user