Skip to content

Commit

Permalink
Use different base image
Browse files Browse the repository at this point in the history
Signed-off-by: David Graeff <[email protected]>
  • Loading branch information
David Graeff committed Sep 3, 2019
1 parent a8aaded commit 36dcda8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 64 deletions.
63 changes: 11 additions & 52 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,67 +1,26 @@
FROM rust:1.35.0-slim
FROM liuchong/rustup:1.37.0-musl

LABEL name="rust-musl-builder"
LABEL name="rust-musl-stable"
LABEL version="1.0.0"
LABEL repository="https://github.com/juankaram/rust-musl-action"
LABEL homepage="https://github.com/juankaram/rust-musl-action"
LABEL maintainer="Juan Karam"
LABEL repository="https://github.com/davidgraeff/rust-musl-action"
LABEL homepage="https://github.com/davidgraeff/rust-musl-action"
LABEL maintainer="David Graeff"

LABEL com.github.actions.name="Rust MUSL Builder"
LABEL com.github.actions.name="Rust MUSL Builder Slim"
LABEL com.github.actions.description="Provides a Rust MUSL environment"
LABEL com.github.actions.icon="settings"
LABEL com.github.actions.color="orange"

RUN apt-get update && apt-get install -y zip build-essential musl-tools pkg-config libssl-dev

ENV BUILD_DIR=/build \
OUTPUT_DIR=/output \
RUST_BACKTRACE=1 \
RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
PREFIX=/toolchain \
MUSL_VERSION=1.1.22 \
OPENSSL_VERSION=1.1.0k \
BUILD_TARGET=x86_64-unknown-linux-musl

RUN mkdir -p /usr/local/cargo/bin \
&& mkdir -p $BUILD_DIR \
&& mkdir -p $OUTPUT_DIR \
&& mkdir -p $PREFIX

WORKDIR $PREFIX

ADD http://www.musl-libc.org/releases/musl-$MUSL_VERSION.tar.gz .
RUN tar -xvzf musl-$MUSL_VERSION.tar.gz \
&& cd musl-$MUSL_VERSION \
&& ./configure --prefix=$PREFIX \
&& make install \
&& cd ..

ENV CC=$PREFIX/bin/musl-gcc \
C_INCLUDE_PATH=$PREFIX/include/ \
CPPFLAGS=-I$PREFIX/include \
LDFLAGS=-L$PREFIX/lib

ADD https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz .

RUN echo "Building OpenSSL" \
&& tar -xzf "openssl-$OPENSSL_VERSION.tar.gz" \
&& cd openssl-$OPENSSL_VERSION \
&& ./Configure no-async no-afalgeng no-shared no-zlib -fPIC --prefix=$PREFIX --openssldir=$PREFIX/ssl linux-x86_64 \
&& make depend \
&& make install

ENV OPENSSL_DIR=$PREFIX \
OPENSSL_STATIC=true
BUILD_TARGET=x86_64-unknown-linux-musl \
OPENSSL_LIB_DIR=/usr/local/ssl/lib \
OPENSSL_INCLUDE_DIR=/usr/local/ssl/include \
OPENSSL_STATIC=1

RUN mkdir -p $BUILD_DIR && mkdir -p $OUTPUT_DIR
WORKDIR $BUILD_DIR

RUN rustup self update && rustup update
RUN rustup target add $BUILD_TARGET
RUN rustup component add clippy-preview
RUN rustup component add rustfmt-preview
RUN cargo install cargo-release

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
# GitHub Action for Rust and MUSL

Action provides an environment with Rust, MUSL and x86_64-unknown-linux-musl target.
Action provides an environment with stable Rust 1.37, MUSL and x86_64-unknown-linux-musl target.

## Usage

To compile a rust binary/library with x86_64-unknown-linux-musl target:

```hcl
action "build" {
env = {
BUILD_TARGET = "x86_64-unknown-linux-musl"
}
uses = "juankaram/rust-musl-action@master"
args = "cargo build --target $BUILD_TARGET --release"
}
```
```yaml
name: Static Musl Build

on: [push]

## Attribution
jobs:
build:

Heavily inspired by [GitHub Actions](https://github.com/actions), [Rust Action](https://github.com/icepuma/rust-action) and [David Lewis Work](https://github.com/davidarmstronglewis).
runs-on: ubuntu-latest
steps:
- uses: davidgraeff/rust-musl-action@master
- uses: actions/checkout@master
- name: Build and Test
run: cargo test --target x86_64-unknown-linux-musl
```
## License
Expand Down

0 comments on commit 36dcda8

Please sign in to comment.