Skip to content

Commit

Permalink
chore(cross): Reduce image size
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Jul 29, 2024
1 parent 1a38586 commit 7de55a2
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion rust/cubestore/cross/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ docker buildx bake x86_64-unknown-linux-gnu-python --push
docker buildx bake aarch64-unknown-linux-gnu-python --push
docker buildx bake x86_64-unknown-linux-musl-python --push

export CROSS_VERSION=15082024
export CROSS_VERSION=01082024

# Verify versions
docker run --platform linux/amd64 --rm -it cubejs/rust-cross:x86_64-unknown-linux-gnu-$CROSS_VERSION cc --version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VER
&& make install \
&& cd .. && rm -rf Python-${PYTHON_VERSION} \
&& rm -rf /var/lib/apt/lists/*; \

ENV PYO3_CROSS_PYTHON_VERSION=${PYTHON_RELEASE} \
PYO3_CROSS_INCLUDE_DIR=/usr/aarch64-linux-gnu/include \
PYO3_CROSS_LIB_DIR=/usr/aarch64-linux-gnu/lib
23 changes: 10 additions & 13 deletions rust/cubestore/cross/aarch64-unknown-linux-gnu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN apt-get update \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y libffi-dev binutils-multiarch binutils-aarch64-linux-gnu gcc-multilib g++-multilib \
# llvm14-dev will install python 3.8 as bin/python3
&& DEBIAN_FRONTEND=noninteractive apt-get install -y llvm-$LLVM_VERSION lld-$LLVM_VERSION clang-$LLVM_VERSION libclang-$LLVM_VERSION-dev clang-$LLVM_VERSION \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y llvm-$LLVM_VERSION lld-$LLVM_VERSION clang-$LLVM_VERSION libclang-$LLVM_VERSION-dev \
make cmake libsasl2-dev \
libc6 libc6-dev libc6-arm64-cross libc6-dev-arm64-cross \
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \
Expand Down Expand Up @@ -47,19 +47,16 @@ RUN wget https://zlib.net/zlib-${ZLIB_VERSION}.tar.gz -O - | tar -xz && \

# https://www.openssl.org/source/old/1.1.1/
ENV OPENSSL_VERSION=1.1.1w
RUN wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz -O - | tar -xz &&\
cd openssl-${OPENSSL_VERSION} && \
./Configure --prefix=/usr/aarch64-linux-gnu --openssldir=/usr/aarch64-linux-gnu/lib linux-aarch64 && \
make depend && \
make -j $(nproc) && \
make install_sw && \
make install_ssldirs && \
cd .. && rm -rf openssl-${OPENSSL_VERSION}
RUN wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz -O - | tar -xz \
&& cd openssl-${OPENSSL_VERSION} \
&& ./Configure --prefix=/usr/aarch64-linux-gnu --openssldir=/usr/aarch64-linux-gnu/lib linux-aarch64 \
&& make depend \
&& make -j $(nproc) \
&& make install_sw \
&& make install_ssldirs \
&& cd .. && rm -rf openssl-${OPENSSL_VERSION}

ENV PYO3_CROSS_PYTHON_VERSION=3.11 \
PYO3_CROSS_INCLUDE_DIR=/usr/aarch64-linux-gnu/include \
PYO3_CROSS_LIB_DIR=/usr/aarch64-linux-gnu/lib \
OPENSSL_DIR=/usr/aarch64-linux-gnu \
ENV OPENSSL_DIR=/usr/aarch64-linux-gnu \
OPENSSL_STATIC=yes \
OPENSSL_INCLUDE_DIR=/usr/aarch64-linux-gnu/include \
OPENSSL_LIB_DIR=/usr/aarch64-linux-gnu/lib \
Expand Down
2 changes: 1 addition & 1 deletion rust/cubestore/cross/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variable "CROSS_VERSION" {
default = "15082024"
default = "01082024"
}

variable "LLVM_VERSION" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@ RUN cd tmp && wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${
&& ln -f -s /usr/bin/python${PYTHON_RELEASE} /usr/bin/python3 \
&& cd .. && rm -rf Python-${PYTHON_VERSION};

# pyo3 uses python3 to detect version, but there is a bug and it uses python3.9 (system), this force it to use a new python
ENV PYO3_PYTHON=python${PYTHON_RELEASE}

ENV PATH="/cargo/bin:$PATH"
4 changes: 2 additions & 2 deletions rust/cubestore/cross/x86_64-unknown-linux-gnu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apt-get update && apt-get -y upgrade \
&& wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \
&& add-apt-repository "deb https://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-$LLVM_VERSION main" \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y llvm-${LLVM_VERSION} lld-${LLVM_VERSION} clang-$LLVM_VERSION libclang-${LLVM_VERSION}-dev clang-$LLVM_VERSION make cmake \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y llvm-${LLVM_VERSION} lld-${LLVM_VERSION} clang-$LLVM_VERSION libclang-${LLVM_VERSION}-dev make cmake \
lzma-dev liblzma-dev libpython3-dev \
&& rm -rf /var/lib/apt/lists/*;

Expand All @@ -28,7 +28,7 @@ RUN cd tmp && wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar
&& make -j $(nproc) \
&& make install_sw \
&& make install_ssldirs \
&& cd .. && rm -rf ${OPENSSL_VERSION}
&& cd .. && rm -rf openssl-${OPENSSL_VERSION}

ENV PKG_CONFIG_ALLOW_CROSS=1
ENV OPENSSL_STATIC=true
Expand Down
18 changes: 9 additions & 9 deletions rust/cubestore/cross/x86_64-unknown-linux-musl.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN apt-get update \
&& add-apt-repository -y ppa:deadsnakes/ppa \
&& apt-get update \
# llvm14-dev will install python 3.8 as bin/python3
&& DEBIAN_FRONTEND=noninteractive apt-get install -y llvm-${LLVM_VERSION} lld-${LLVM_VERSION} clang-${LLVM_VERSION} libclang-${LLVM_VERSION}-dev clang-${LLVM_VERSION} make cmake \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y llvm-${LLVM_VERSION} lld-${LLVM_VERSION} clang-${LLVM_VERSION} libclang-${LLVM_VERSION}-dev make cmake \
&& rm -rf /var/lib/apt/lists/*;

RUN ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/x86_64-linux-musl/asm && \
Expand All @@ -24,14 +24,14 @@ RUN mkdir /musl

# https://www.openssl.org/source/old/1.1.1/
ARG OPENSSL_VERSION=1.1.1w
RUN wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz -O - | tar -xz &&\
cd openssl-${OPENSSL_VERSION} && \
CC="musl-gcc -fPIE -pie" ./Configure no-shared no-async --prefix=/musl --openssldir=/musl/ssl linux-x86_64 && \
make depend && \
make -j $(nproc) && \
make install_sw && \
make install_ssldirs && \
cd .. && rm -rf openssl-${OPENSSL_VERSION}
RUN wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz -O - | tar -xz \
&& cd openssl-${OPENSSL_VERSION} \
&& CC="musl-gcc -fPIE -pie" ./Configure no-shared no-async --prefix=/musl --openssldir=/musl/ssl linux-x86_64 \
&& make depend \
&& make -j $(nproc) \
&& make install_sw \
&& make install_ssldirs \
&& cd .. && rm -rf openssl-${OPENSSL_VERSION}

ENV PKG_CONFIG_ALLOW_CROSS=true
ENV PKG_CONFIG_ALL_STATIC=true
Expand Down

0 comments on commit 7de55a2

Please sign in to comment.