parent
348bf4a90a
commit
745dcb7ff8
11 changed files with 129 additions and 22 deletions
@ -0,0 +1,3 @@ |
|||||||
|
[build] |
||||||
|
rustflags = ["-L", "/home/ortem/src/rust/unki/static/lib"] |
||||||
|
target = "x86_64-unknown-linux-musl" |
@ -0,0 +1,96 @@ |
|||||||
|
FROM ubuntu:xenial |
||||||
|
LABEL maintainer="Eirik Albrigtsen <sszynrae@gmail.com>" |
||||||
|
|
||||||
|
# Required packages: |
||||||
|
# - musl-dev, musl-tools - the musl toolchain |
||||||
|
# - curl, g++, make, pkgconf, cmake - for fetching and building third party libs |
||||||
|
# - ca-certificates - openssl + curl + peer verification of downloads |
||||||
|
# - xutils-dev - for openssl makedepend |
||||||
|
# - libssl-dev and libpq-dev - for dynamic linking during diesel_codegen build process |
||||||
|
# - git - cargo builds in user projects |
||||||
|
# - linux-headers-amd64 - needed for building openssl 1.1 (stretch only) |
||||||
|
# - file - needed by rustup.sh install |
||||||
|
# - automake autoconf libtool - support crates building C deps as part cargo build |
||||||
|
# recently removed: |
||||||
|
# cmake (not used), nano, zlib1g-dev |
||||||
|
RUN apt-get update && apt-get install -y \ |
||||||
|
musl-dev \ |
||||||
|
musl-tools \ |
||||||
|
git \ |
||||||
|
file \ |
||||||
|
openssh-client \ |
||||||
|
make \ |
||||||
|
g++ \ |
||||||
|
curl \ |
||||||
|
pkgconf \ |
||||||
|
ca-certificates \ |
||||||
|
xutils-dev \ |
||||||
|
libssl-dev \ |
||||||
|
libpq-dev \ |
||||||
|
automake \ |
||||||
|
autoconf \ |
||||||
|
libtool \ |
||||||
|
python3 \ |
||||||
|
--no-install-recommends && \ |
||||||
|
rm -rf /var/lib/apt/lists/* |
||||||
|
|
||||||
|
# Convenience list of versions and variables for compilation later on |
||||||
|
# This helps continuing manually if anything breaks. |
||||||
|
ENV SSL_VER="1.0.2u" \ |
||||||
|
CURL_VER="7.77.0" \ |
||||||
|
ZLIB_VER="1.2.11" \ |
||||||
|
PQ_VER="11.12" \ |
||||||
|
SQLITE_VER="3350500" \ |
||||||
|
CC=musl-gcc \ |
||||||
|
PREFIX=/musl \ |
||||||
|
PATH=/usr/local/bin:/root/.cargo/bin:$PATH \ |
||||||
|
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig \ |
||||||
|
LD_LIBRARY_PATH=$PREFIX |
||||||
|
|
||||||
|
# Set up a prefix for musl build libraries, make the linker's job of finding them easier |
||||||
|
# Primarily for the benefit of postgres. |
||||||
|
# Lastly, link some linux-headers for openssl 1.1 (not used herein) |
||||||
|
RUN mkdir $PREFIX && \ |
||||||
|
echo "$PREFIX/lib" >> /etc/ld-musl-x86_64.path && \ |
||||||
|
ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/x86_64-linux-musl/asm && \ |
||||||
|
ln -s /usr/include/asm-generic /usr/include/x86_64-linux-musl/asm-generic && \ |
||||||
|
ln -s /usr/include/linux /usr/include/x86_64-linux-musl/linux |
||||||
|
|
||||||
|
# Build zlib (used in openssl and pq) |
||||||
|
RUN curl -sSL https://zlib.net/zlib-$ZLIB_VER.tar.gz | tar xz && \ |
||||||
|
cd zlib-$ZLIB_VER && \ |
||||||
|
CC="musl-gcc -fPIC -pie" LDFLAGS="-L$PREFIX/lib" CFLAGS="-I$PREFIX/include" ./configure --static --prefix=$PREFIX && \ |
||||||
|
make -j$(nproc) && make install && \ |
||||||
|
cd .. && rm -rf zlib-$ZLIB_VER |
||||||
|
|
||||||
|
# Build openssl (used in curl and pq) |
||||||
|
# Would like to use zlib here, but can't seem to get it to work properly |
||||||
|
# TODO: fix so that it works |
||||||
|
RUN curl -sSL https://www.openssl.org/source/old/1.0.2/openssl-$SSL_VER.tar.gz | tar xz && \ |
||||||
|
cd openssl-$SSL_VER && \ |
||||||
|
./Configure no-zlib no-shared -fPIC --prefix=$PREFIX --openssldir=$PREFIX/ssl linux-x86_64 && \ |
||||||
|
env C_INCLUDE_PATH=$PREFIX/include make depend 2> /dev/null && \ |
||||||
|
make -j$(nproc) && make install && \ |
||||||
|
cd .. && rm -rf openssl-$SSL_VER |
||||||
|
|
||||||
|
# Build curl (needs with-zlib and all this stuff to allow https) |
||||||
|
# curl_LDFLAGS needed on stretch to avoid fPIC errors - though not sure from what |
||||||
|
RUN curl -sSL https://curl.se/download/curl-$CURL_VER.tar.gz | tar xz && \ |
||||||
|
cd curl-$CURL_VER && \ |
||||||
|
CC="musl-gcc -fPIC -pie" LDFLAGS="-L$PREFIX/lib" CFLAGS="-I$PREFIX/include" ./configure \ |
||||||
|
--enable-shared=no --with-zlib --enable-static=ssl --enable-optimize --prefix=$PREFIX \ |
||||||
|
--with-ca-path=/etc/ssl/certs/ --with-ca-bundle=/etc/ssl/certs/ca-certificates.crt --without-ca-fallback \ |
||||||
|
--with-openssl && \ |
||||||
|
make -j$(nproc) curl_LDFLAGS="-all-static" && make install && \ |
||||||
|
cd .. && rm -rf curl-$CURL_VER |
||||||
|
|
||||||
|
# Build libpq |
||||||
|
RUN curl -sSL https://ftp.postgresql.org/pub/source/v$PQ_VER/postgresql-$PQ_VER.tar.gz | tar xz && \ |
||||||
|
cd postgresql-$PQ_VER && \ |
||||||
|
CC="musl-gcc -fPIE -pie" LDFLAGS="-L$PREFIX/lib" CFLAGS="-I$PREFIX/include" ./configure \ |
||||||
|
--without-readline \ |
||||||
|
--with-openssl \ |
||||||
|
--prefix=$PREFIX --host=x86_64-unknown-linux-musl && \ |
||||||
|
cd src/interfaces/libpq make -s -j$(nproc) all-static-lib && make -s install install-lib-static && \ |
||||||
|
cd ../../bin/pg_config && make -j $(nproc) && make install && \ |
||||||
|
cd .. && rm -rf postgresql-$PQ_VER |
@ -0,0 +1,15 @@ |
|||||||
|
#!/bin/bash |
||||||
|
set -ex |
||||||
|
source $(dirname $0)/rootdir.sh #set ROOTDIR |
||||||
|
ARGS=$@ |
||||||
|
STATIC_LIBS=static |
||||||
|
DOCKER_EXCHG=/musl-share |
||||||
|
IMAGE=unki/musllibs |
||||||
|
mkdir -p $STATIC_LIBS |
||||||
|
cd $ROOTDIR/images && docker build -t $IMAGE . -f musl-libs.Dockerfile |
||||||
|
docker run \ |
||||||
|
-v $ROOTDIR/$STATIC_LIBS:$DOCKER_EXCHG \ |
||||||
|
-w /volume \ |
||||||
|
-it \ |
||||||
|
$IMAGE \ |
||||||
|
bash -c "[[ \$(ls -A $DOCKER_EXCHG) ]] || cp /musl/. $DOCKER_EXCHG -r" |
@ -1,13 +0,0 @@ |
|||||||
#!/bin/bash |
|
||||||
set -ex |
|
||||||
source $(dirname $0)/rootdir.sh #set ROOTDIR |
|
||||||
ARGS=$@ |
|
||||||
docker run \ |
|
||||||
--env-file $ROOTDIR/.env \ |
|
||||||
--env-file $ROOTDIR/.env.private \ |
|
||||||
-v $ROOTDIR:/volume \ |
|
||||||
-v cargo-cache:/root/.cargo/registry \ |
|
||||||
-w /volume \ |
|
||||||
-it \ |
|
||||||
unki/musllibs \ |
|
||||||
bash -c "umask 0000; cargo $ARGS" |
|
Loading…
Reference in new issue