-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a8aaded
Showing
5 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.git | ||
.github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
FROM rust:1.35.0-slim | ||
|
||
LABEL name="rust-musl-builder" | ||
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 com.github.actions.name="Rust MUSL Builder" | ||
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 | ||
|
||
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2018 Juan Karam, GitHub, Inc. and contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# GitHub Action for Rust and MUSL | ||
|
||
Action provides an environment with Rust, 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" | ||
} | ||
``` | ||
|
||
## Attribution | ||
|
||
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). | ||
|
||
## License | ||
|
||
The Dockerfile and associated scripts and documentation in this project are released under the [MIT License](LICENSE). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
set -e -u -o pipefail | ||
cd $GITHUB_WORKSPACE | ||
bash -c "$*" |