2023-05-25 16:05:53 +00:00
|
|
|
FROM ghcr.io/cross-rs/x86_64-unknown-linux-musl:latest
|
|
|
|
|
2023-09-05 08:36:23 +00:00
|
|
|
ENV ZLIB_VERSION=1.3
|
|
|
|
ENV POSTGRESQL_VERSION=11.21
|
|
|
|
ENV OPENSSL_VERSION=3.1.2
|
2023-05-26 15:02:19 +00:00
|
|
|
ENV OPENSSL_TARGET=linux-x86_64
|
2023-05-25 16:05:53 +00:00
|
|
|
ENV MUSL_PREFIX=x86_64-linux-musl
|
|
|
|
|
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get --assume-yes install \
|
2023-05-26 15:02:19 +00:00
|
|
|
protobuf-compiler \
|
|
|
|
libprotobuf-dev
|
2023-05-25 16:05:53 +00:00
|
|
|
|
|
|
|
RUN echo "Building OpenSSL" && \
|
|
|
|
cd /tmp && \
|
|
|
|
curl -fLO "https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz" && \
|
|
|
|
tar xvzf "openssl-$OPENSSL_VERSION.tar.gz" && cd "openssl-$OPENSSL_VERSION" && \
|
2023-05-26 15:02:19 +00:00
|
|
|
env CC=$MUSL_PREFIX-gcc ./Configure no-shared no-zlib -fPIC --prefix=/usr/local/$MUSL_PREFIX-target -DOPENSSL_NO_SECURE_MEMORY $OPENSSL_TARGET && \
|
2023-05-25 16:05:53 +00:00
|
|
|
env C_INCLUDE_PATH=/usr/local/$MUSL_PREFIX/include/ make depend && \
|
|
|
|
env C_INCLUDE_PATH=/usr/local/$MUSL_PREFIX/include/ make && \
|
|
|
|
make install_sw && \
|
|
|
|
rm -r /tmp/*
|
|
|
|
|
|
|
|
RUN echo "Building zlib" && \
|
|
|
|
cd /tmp && \
|
|
|
|
curl -fLO "https://zlib.net/zlib-$ZLIB_VERSION.tar.gz" && \
|
|
|
|
tar xzf "zlib-$ZLIB_VERSION.tar.gz" && cd "zlib-$ZLIB_VERSION" && \
|
|
|
|
CC=$MUSL_PREFIX-gcc ./configure --static --prefix=/usr/local/$MUSL_PREFIX-target && \
|
|
|
|
make && make install && \
|
|
|
|
rm -r /tmp/*
|
|
|
|
|
|
|
|
RUN echo "Building libpq" && \
|
|
|
|
cd /tmp && \
|
|
|
|
curl -fLO "https://ftp.postgresql.org/pub/source/v$POSTGRESQL_VERSION/postgresql-$POSTGRESQL_VERSION.tar.gz" && \
|
|
|
|
tar xzf "postgresql-$POSTGRESQL_VERSION.tar.gz" && cd "postgresql-$POSTGRESQL_VERSION" && \
|
2023-09-05 08:36:23 +00:00
|
|
|
CC=$MUSL_PREFIX-gcc CPPFLAGS="-I/usr/local/$MUSL_PREFIX/include -I/usr/local/$MUSL_PREFIX-target/include" LDFLAGS="-L/usr/local/$MUSL_PREFIX/lib -L/usr/local/$MUSL_PREFIX-target/lib -L/usr/local/$MUSL_PREFIX-target/lib64" ./configure --with-openssl --without-readline --prefix=/usr/local/$MUSL_PREFIX-target && \
|
2023-05-25 16:05:53 +00:00
|
|
|
cd src/interfaces/libpq && make all-static-lib && make install-lib-static && \
|
|
|
|
rm -r /tmp/*
|
|
|
|
|
|
|
|
# Workaround for re-defined unicode_to_utf8 which also exists in quickjs library.
|
|
|
|
RUN objcopy --redefine-sym unicode_to_utf8=unicode_to_utf8_rename /usr/local/$MUSL_PREFIX-target/lib/libpq.a
|
|
|
|
|
|
|
|
|
2023-09-05 08:36:23 +00:00
|
|
|
ENV PKG_CONFIG_PATH=/usr/local/$MUSL_PREFIX-target/lib/pkgconfig:/usr/local/$MUSL_PREFIX-target/lib64/pkgconfig
|