Skip to content

Commit 80d3e14

Browse files
committed
Remove all crossbuild stuff, we are building on target archs now
1 parent f9e6126 commit 80d3e14

9 files changed

Lines changed: 62 additions & 173 deletions

Dockerfile

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,29 @@
11
# Use Debian Bullseye as a base image to link against glibc 2.31
2-
FROM --platform=${BUILDPLATFORM} debian:bullseye-slim AS base
2+
FROM debian:bullseye-slim AS base
33

4-
ARG TARGETARCH
5-
6-
RUN dpkg --add-architecture ${TARGETARCH} \
7-
&& apt-get update \
4+
RUN apt-get update \
85
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
96
bash \
107
curl \
118
git \
129
ca-certificates \
13-
crossbuild-essential-${TARGETARCH} \
10+
build-essential \
1411
pkg-config \
1512
libssl-dev \
16-
libstdc++-10-dev:${TARGETARCH}
13+
libstdc++-10-dev
1714

1815
WORKDIR /root
1916

2017
# ==============================================================================
2118

22-
FROM --platform=${BUILDPLATFORM} base AS deps-src
19+
FROM base AS deps-src
2320

2421
COPY versions.sh download-deps.sh ./
2522
RUN ./download-deps.sh
2623

2724
# ==============================================================================
2825

29-
FROM --platform=${BUILDPLATFORM} base AS deps
30-
31-
ARG TARGETARCH
26+
FROM base AS deps
3227

3328
COPY install-rust.sh ./
3429

@@ -47,10 +42,10 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
4742
&& python3 -m venv /root/.python \
4843
&& /root/.python/bin/pip install meson ninja packaging
4944

50-
COPY versions.sh build-deps.sh build-bash-profile.sh *.patch cmake_${TARGETARCH}.cmake meson_${TARGETARCH}.ini ./
45+
COPY versions.sh build-deps.sh build-bash-profile.sh *.patch ./
5146
COPY --from=deps-src /root/deps /root/deps
5247

53-
# We need environment variables that based on the TARGETARCH,
48+
# We need environment variables that are based on the uname -m output,
5449
# so we have to use a Bash profile instead of ENV
5550
RUN ./build-bash-profile.sh > /root/.bashrc
5651
ENV BASH_ENV=/root/.bashrc
@@ -59,21 +54,17 @@ RUN ./build-deps.sh
5954

6055
# ==============================================================================
6156

62-
FROM --platform=${BUILDPLATFORM} base as golang
57+
FROM base AS golang
6358

6459
COPY versions.sh install-go.sh ./
6560
RUN ./install-go.sh
6661

6762
# ==============================================================================
6863

69-
FROM --platform=${TARGETPLATFORM} debian:bullseye-slim AS final
64+
FROM debian:bullseye-slim AS final
7065
LABEL maintainer="Sergey Alexandrovich <darthsim@gmail.com>"
7166

72-
ARG TARGETARCH
73-
ARG BUILDARCH
74-
75-
RUN dpkg --add-architecture ${BUILDARCH} \
76-
&& apt-get update \
67+
RUN apt-get update \
7768
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
7869
bash \
7970
curl \
@@ -87,7 +78,7 @@ RUN dpkg --add-architecture ${BUILDARCH} \
8778
WORKDIR /root
8879

8980
COPY --from=golang /usr/local/go /usr/local/go
90-
ENV PATH $PATH:/usr/local/go/bin
81+
ENV PATH=$PATH:/usr/local/go/bin
9182

9283
COPY --from=deps /opt/imgproxy/lib /opt/imgproxy/lib
9384
COPY --from=deps /opt/imgproxy/include /opt/imgproxy/include
@@ -97,4 +88,4 @@ COPY --from=deps /root/.bashrc /root/.bashrc
9788
ENV BASH_ENV=/root/.bashrc
9889

9990
WORKDIR /app
100-
CMD bash
91+
CMD ["bash"]

build-bash-profile.sh

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,36 @@
22

33
set -e
44

5-
case "$TARGETARCH" in
6-
7-
amd64)
8-
ARCH="x86_64"
5+
case "$(uname -m)" in
6+
x86_64)
7+
ARCH_ENV=$(cat << EOF
8+
export CFLAGS="-mssse3"
9+
EOF
10+
)
911
;;
1012

11-
arm64)
12-
ARCH="aarch64"
13+
aarch64)
14+
ARCH_ENV=$(cat << EOF
15+
export CFLAGS="-march=armv8.2-a+fp16"
16+
EOF
17+
)
1318
;;
1419

1520
*)
16-
echo "Unknows arch: $TARGETARCH"
21+
echo "Unsupported architecture $(uname -m)"
1722
exit 1
23+
;;
1824
esac
1925

20-
ARCH_ENV=""
21-
22-
if [ "$TARGETARCH" = "amd64" ]; then
23-
ARCH_ENV=$(cat << EOF
24-
export CFLAGS="-mssse3"
25-
EOF
26-
)
27-
fi
28-
29-
if [ "$TARGETARCH" = "arm64" ]; then
30-
ARCH_ENV=$(cat << EOF
31-
export CFLAGS="-march=armv8.2-a+fp16"
32-
EOF
33-
)
34-
fi
35-
3626
cat << EOF
3727
export PATH="/opt/imgproxy/bin:/root/.cargo/bin:/root/.python/bin:\$PATH"
3828
export PKG_CONFIG_LIBDIR=/opt/imgproxy/lib/pkgconfig
3929
export CGO_LDFLAGS_ALLOW="-s|-w"
4030
export CGO_LDFLAGS="-Wl,-rpath,/opt/imgproxy/lib"
4131
4232
$ARCH_ENV
43-
export BUILD=$(uname -m)-linux-gnu
44-
export HOST=$ARCH-linux-gnu
45-
export CC=$ARCH-linux-gnu-gcc
46-
export CXX=$ARCH-linux-gnu-g++
47-
export STRIP=$ARCH-linux-gnu-strip
4833
export CFLAGS="\$CFLAGS -Os -fPIC -D_GLIBCXX_USE_CXX11_ABI=1 -fno-asynchronous-unwind-tables -ffunction-sections -fdata-sections"
4934
export CXXFLAGS=\$CFLAGS
5035
export CPPFLAGS="\$CPPFLAGS -I/opt/imgproxy/include"
5136
export LDFLAGS="\$LDFLAGS -L/opt/imgproxy/lib -Wl,--gc-sections -Wl,-rpath,/opt/imgproxy/lib"
52-
export CMAKE_C_COMPILER=\$CC
53-
export CMAKE_CXX_COMPILER=\$CXX
54-
export CMAKE_CROSS_CONFIG="-DCMAKE_TOOLCHAIN_FILE=/root/cmake_$TARGETARCH.cmake"
55-
export MESON_CROSS_CONFIG="--cross-file=/root/meson_$TARGETARCH.ini"
56-
export CARGO_TARGET="$ARCH-unknown-linux-gnu"
57-
export CARGO_CROSS_CONFIG='[target.$ARCH-unknown-linux-gnu]\nlinker = "$ARCH-linux-gnu-gcc"'
5837
EOF

0 commit comments

Comments
 (0)