Fix Docker builds for arm
This commit is contained in:
parent
c7c1a3ebae
commit
ef063df34d
|
@ -28,6 +28,8 @@ RUN chmod +x /tmp/install_build_dependencies.sh && /tmp/install_build_dependenci
|
||||||
|
|
||||||
COPY docker/go_wrapper.sh /go/bin/go
|
COPY docker/go_wrapper.sh /go/bin/go
|
||||||
RUN chmod +x /go/bin/go
|
RUN chmod +x /go/bin/go
|
||||||
|
ENV GOPATH="/go"
|
||||||
|
ENV PATH="${GOPATH}/bin:${PATH}"
|
||||||
|
|
||||||
ENV CGO_ENABLED 1
|
ENV CGO_ENABLED 1
|
||||||
|
|
||||||
|
@ -41,7 +43,7 @@ COPY api/go.mod api/go.sum /app/
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
# Patch go-face
|
# Patch go-face
|
||||||
RUN sed -i 's/-march=native//g' /root/go/pkg/mod/github.com/!kagami/go-face*/face.go
|
RUN sed -i 's/-march=native//g' ${GOPATH}/pkg/mod/github.com/!kagami/go-face*/face.go
|
||||||
|
|
||||||
# Build dependencies that use CGO
|
# Build dependencies that use CGO
|
||||||
RUN go install \
|
RUN go install \
|
||||||
|
|
|
@ -66,39 +66,33 @@ fi
|
||||||
if [ "$CGO_ENABLED" = "1" ]; then
|
if [ "$CGO_ENABLED" = "1" ]; then
|
||||||
case "$GOARCH" in
|
case "$GOARCH" in
|
||||||
"amd64")
|
"amd64")
|
||||||
export CC="x86_64-linux-gnu-gcc"
|
export COMPILER_ARCH="x86_64-linux-gnu"
|
||||||
export CXX="x86_64-linux-gnu-g++"
|
|
||||||
;;
|
;;
|
||||||
"ppc64le")
|
"ppc64le")
|
||||||
export CC="powerpc64le-linux-gnu-gcc"
|
export COMPILER_ARCH="powerpc64le-linux-gnu"
|
||||||
export CXX="powerpc64le-linux-gnu-g++"
|
|
||||||
;;
|
;;
|
||||||
"s390x")
|
"s390x")
|
||||||
export CC="s390x-linux-gnu-gcc"
|
export COMPILER_ARCH="s390x-linux-gnu"
|
||||||
export CXX="s390x-linux-gnu-g++"
|
|
||||||
;;
|
;;
|
||||||
"arm64")
|
"arm64")
|
||||||
export CC="aarch64-linux-gnu-gcc"
|
export COMPILER_ARCH="aarch64-linux-gnu"
|
||||||
export CXX="aarch64-linux-gnu-g++"
|
|
||||||
;;
|
;;
|
||||||
"arm")
|
"arm")
|
||||||
case "$GOARM" in
|
case "$GOARM" in
|
||||||
"5")
|
"5")
|
||||||
export CC="arm-linux-gnueabi-gcc"
|
export COMPILER_ARCH="arm-linux-gnueabi"
|
||||||
export CXX="arm-linux-gnueabi-g++"
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
export CC="arm-linux-gnueabihf-gcc"
|
export COMPILER_ARCH="arm-linux-gnueabihf"
|
||||||
export CXX="arm-linux-gnueabihf-g++"
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$GOOS" = "wasi" ]; then
|
export CC="${COMPILER_ARCH}-gcc"
|
||||||
export GOOS="js"
|
export CXX="${COMPILER_ARCH}-g++"
|
||||||
fi
|
export PKG_CONFIG_PATH="/usr/lib/${COMPILER_ARCH}/pkgconfig/"
|
||||||
|
|
||||||
if [ -z "$GOBIN" ] && [ -n "$GOPATH" ] && [ -n "$GOARCH" ] && [ -n "$GOOS" ]; then
|
if [ -z "$GOBIN" ] && [ -n "$GOPATH" ] && [ -n "$GOARCH" ] && [ -n "$GOOS" ]; then
|
||||||
export PATH=${GOPATH}/bin/${GOOS}_${GOARCH}:${PATH}
|
export PATH=${GOPATH}/bin/${GOOS}_${GOARCH}:${PATH}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
if [ "$TARGETPLATFORM" == "linux/arm64" ]; then
|
if [ "$TARGETPLATFORM" == "linux/arm64" ]; then
|
||||||
dpkg --add-architecture arm64
|
dpkg --add-architecture arm64
|
||||||
|
@ -12,26 +13,27 @@ fi
|
||||||
|
|
||||||
apt-get update
|
apt-get update
|
||||||
|
|
||||||
|
# Install G++/GCC cross compilers
|
||||||
|
if [ "$DEBIAN_ARCH" == "arm64" ]; then
|
||||||
|
apt-get install -y \
|
||||||
|
g++-aarch64-linux-gnu \
|
||||||
|
libc6-dev-arm64-cross
|
||||||
|
elif [ "$DEBIAN_ARCH" == "armhf" ]; then
|
||||||
|
apt-get install -y \
|
||||||
|
g++-arm-linux-gnueabihf \
|
||||||
|
libc6-dev-armhf-cross
|
||||||
|
fi
|
||||||
|
|
||||||
# Install Golang
|
# Install Golang
|
||||||
apt-get install -y ca-certificates golang
|
apt-get install -y ca-certificates golang
|
||||||
|
|
||||||
# Install G++/GCC cross compilers
|
# Install go-face dependencies and libheif for HEIF media decoding
|
||||||
apt-get install -y \
|
apt-get install -y \
|
||||||
g++-aarch64-linux-gnu \
|
libdlib-dev:${DEBIAN_ARCH} \
|
||||||
libc6-dev-arm64-cross \
|
libblas-dev:${DEBIAN_ARCH} \
|
||||||
g++-arm-linux-gnueabihf \
|
liblapack-dev:${DEBIAN_ARCH} \
|
||||||
libc6-dev-armhf-cross
|
libjpeg-dev:${DEBIAN_ARCH} \
|
||||||
|
libheif-dev:${DEBIAN_ARCH}
|
||||||
# Install go-face dependencies
|
|
||||||
apt-get install -y \
|
|
||||||
libdlib-dev:$DEBIAN_ARCH \
|
|
||||||
libblas-dev:$DEBIAN_ARCH \
|
|
||||||
liblapack-dev:$DEBIAN_ARCH \
|
|
||||||
libjpeg62-turbo-dev:$DEBIAN_ARCH \
|
|
||||||
|
|
||||||
# Install libheif for HEIF media decoding
|
|
||||||
apt-get install -y \
|
|
||||||
libheif-dev:$DEBIAN_ARCH
|
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
apt-get clean
|
apt-get clean
|
||||||
|
|
Loading…
Reference in New Issue