EarthlyでRaspberryPi向けにビルドする
Earthlyはコンテナビルドツールとして便利だが、組み込みのような開発環境構築が面倒なビルドにも便利
RaspberryPi向けの
ただhyper
とかtokio::net
とかopenssl
やらring
やらaarch64-linux-musl-gcc
をcross
ではbuildx
で
Earthlyはmake
+ Docker
とMakefile
っぽく
サンプルは
Rustをmain.rs
をreqwest
にdefault-features=false, features=["rustls-webpki-roots"]
をopenssl
とca-certificates
へのnative-tls
での
FROM
文でaarch64
向けの
VERSION 0.6
FROM rust:latest@sha256:97fa23369c500e6b41bf9091b4af614e6728498c81a0c1717c73480085eefb9e
WORKDIR /work
all:
BUILD +build
build:
RUN mkdir src
RUN echo "fn main(){}" > src/main.rs
COPY Cargo.toml .
COPY Cargo.lock .
RUN apt-get update && apt-get install -y musl-dev musl-tools
RUN ln -sf $(which musl-gcc) /usr/local/bin/aarch64-linux-musl-gcc
RUN rustup target install aarch64-unknown-linux-musl
RUN cargo build --release --target=aarch64-unknown-linux-musl
COPY src src
RUN cargo build --release --target=aarch64-unknown-linux-musl
SAVE ARTIFACT target/aarch64-unknown-linux-musl/release/something-awesome AS LOCAL something-awesome