|
| 1 | +FROM rust:1.35.0-slim |
| 2 | + |
| 3 | +LABEL name="rust-musl-builder" |
| 4 | +LABEL version="1.0.0" |
| 5 | +LABEL repository="https://github.com/juankaram/rust-musl-action" |
| 6 | +LABEL homepage="https://github.com/juankaram/rust-musl-action" |
| 7 | +LABEL maintainer="Juan Karam" |
| 8 | + |
| 9 | +LABEL com.github.actions.name="Rust MUSL Builder" |
| 10 | +LABEL com.github.actions.description="Provides a Rust MUSL environment" |
| 11 | +LABEL com.github.actions.icon="settings" |
| 12 | +LABEL com.github.actions.color="orange" |
| 13 | + |
| 14 | +RUN apt-get update && apt-get install -y zip build-essential musl-tools pkg-config libssl-dev |
| 15 | + |
| 16 | +ENV BUILD_DIR=/build \ |
| 17 | + OUTPUT_DIR=/output \ |
| 18 | + RUST_BACKTRACE=1 \ |
| 19 | + RUSTUP_HOME=/usr/local/rustup \ |
| 20 | + CARGO_HOME=/usr/local/cargo \ |
| 21 | + PATH=/usr/local/cargo/bin:$PATH \ |
| 22 | + PREFIX=/toolchain \ |
| 23 | + MUSL_VERSION=1.1.22 \ |
| 24 | + OPENSSL_VERSION=1.1.0k \ |
| 25 | + BUILD_TARGET=x86_64-unknown-linux-musl |
| 26 | + |
| 27 | +RUN mkdir -p /usr/local/cargo/bin \ |
| 28 | + && mkdir -p $BUILD_DIR \ |
| 29 | + && mkdir -p $OUTPUT_DIR \ |
| 30 | + && mkdir -p $PREFIX |
| 31 | + |
| 32 | +WORKDIR $PREFIX |
| 33 | + |
| 34 | +ADD http://www.musl-libc.org/releases/musl-$MUSL_VERSION.tar.gz . |
| 35 | +RUN tar -xvzf musl-$MUSL_VERSION.tar.gz \ |
| 36 | + && cd musl-$MUSL_VERSION \ |
| 37 | + && ./configure --prefix=$PREFIX \ |
| 38 | + && make install \ |
| 39 | + && cd .. |
| 40 | + |
| 41 | +ENV CC=$PREFIX/bin/musl-gcc \ |
| 42 | + C_INCLUDE_PATH=$PREFIX/include/ \ |
| 43 | + CPPFLAGS=-I$PREFIX/include \ |
| 44 | + LDFLAGS=-L$PREFIX/lib |
| 45 | + |
| 46 | +ADD https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz . |
| 47 | + |
| 48 | +RUN echo "Building OpenSSL" \ |
| 49 | + && tar -xzf "openssl-$OPENSSL_VERSION.tar.gz" \ |
| 50 | + && cd openssl-$OPENSSL_VERSION \ |
| 51 | + && ./Configure no-async no-afalgeng no-shared no-zlib -fPIC --prefix=$PREFIX --openssldir=$PREFIX/ssl linux-x86_64 \ |
| 52 | + && make depend \ |
| 53 | + && make install |
| 54 | + |
| 55 | +ENV OPENSSL_DIR=$PREFIX \ |
| 56 | + OPENSSL_STATIC=true |
| 57 | + |
| 58 | +WORKDIR $BUILD_DIR |
| 59 | + |
| 60 | +RUN rustup self update && rustup update |
| 61 | +RUN rustup target add $BUILD_TARGET |
| 62 | +RUN rustup component add clippy-preview |
| 63 | +RUN rustup component add rustfmt-preview |
| 64 | +RUN cargo install cargo-release |
| 65 | + |
| 66 | +COPY entrypoint.sh /entrypoint.sh |
| 67 | +ENTRYPOINT ["/entrypoint.sh"] |
0 commit comments