From c49c8219ace58683019ce1747a3ca62c206e4814 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 11 Mar 2023 18:12:13 -0500 Subject: [PATCH] Build rust image locally --- build.earth | 100 ++++++++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 46 deletions(-) diff --git a/build.earth b/build.earth index 1495de8..f00383a 100644 --- a/build.earth +++ b/build.earth @@ -38,67 +38,75 @@ docs: SAVE ARTIFACT output/* AS LOCAL build/docs/ -rust-deps: - FROM rust:latest - ENV CARGO_HOME=/deps - WORKDIR /work +# rust-deps: +# FROM rust:latest +# ENV CARGO_HOME=/deps +# WORKDIR /work - COPY ./web/Cargo.toml . - # This is a binary program, expose a main.rs file - RUN mkdir src && touch src/main.rs - RUN cargo fetch - SAVE ARTIFACT /deps +# COPY ./web/Cargo.toml . +# # This is a binary program, expose a main.rs file +# RUN mkdir src && touch src/main.rs +# RUN cargo fetch +# SAVE ARTIFACT /deps -rust-builder: - FROM rust:latest - ENV CARGO_HOME=/deps - WORKDIR /work +# rust-builder: +# FROM rust:latest +# ENV CARGO_HOME=/deps +# WORKDIR /work - # Linux - RUN rustup target add x86_64-unknown-linux-musl +# # Linux +# RUN rustup target add x86_64-unknown-linux-musl - RUN cargo install cargo-deb +# SAVE IMAGE docker-wg:5000/rust-builder - SAVE IMAGE docker-wg:5000/rust-builder +# rust-build: +# FROM +rust-builder -build: - FROM +rust-builder +# COPY +rust-deps/deps /deps - COPY +rust-deps/deps /deps +# ARG TOOLCHAIN - ARG TOOLCHAIN=x86_64-unknown-linux-musl +# # Cache whatever dependency builds you can +# COPY ./web/Cargo.toml . +# RUN \ +# mkdir src && touch src/lib.rs && \ +# cargo build --offline --release --target "$TOOLCHAIN" --jobs 1 && \ +# rm src/lib.rs && rmdir src && \ +# : - # Cache whatever dependency builds you can - COPY ./web/Cargo.toml . - RUN \ - mkdir src && touch src/lib.rs && \ - cargo build --offline --release --target "$TOOLCHAIN" --jobs 1 && \ - rm src/lib.rs && rmdir src && \ - : +# # Actually build the program +# COPY ./web . +# RUN cargo build --offline --release --target "$TOOLCHAIN" --jobs 1 - # Actually build the program - COPY ./web . - RUN cargo build --offline --release --target "$TOOLCHAIN" --jobs 1 +# ARG EXT +# ARG STRIP_CMD=x86_64-linux-gnu-strip +# ARG APP_NAME=web - ARG EXT - ARG STRIP_CMD=x86_64-linux-gnu-strip - ARG APP_NAME=web +# RUN if [ "$STRIP_CMD" ]; then "$STRIP_CMD" "target/$TOOLCHAIN/release/$APP_NAME$EXT"; fi +# # --force for windows since multiple hardlinks +# RUN xz --force --keep "target/$TOOLCHAIN/release/$APP_NAME$EXT" - RUN if [ "$STRIP_CMD" ]; then "$STRIP_CMD" "target/$TOOLCHAIN/release/$APP_NAME$EXT"; fi - # --force for windows since multiple hardlinks - RUN xz --force --keep "target/$TOOLCHAIN/release/$APP_NAME$EXT" +# # SAVE ARTIFACT target/$TOOLCHAIN/release/$APP_NAME$EXT AS LOCAL dist/ +# SAVE ARTIFACT target/$TOOLCHAIN/release/$APP_NAME$EXT.xz AS LOCAL dist/$APP_NAME-$TOOLCHAIN$EXT.xz - # Also build a deb file - IF [ -z "${TOOLCHAIN##*-linux-*}" ] - RUN echo "Building deb for ${TOOLCHAIN}" - RUN cargo deb --target "${TOOLCHAIN}" +rust-image: + FROM scratch - SAVE ARTIFACT target/$TOOLCHAIN/debian/$APP_NAME_*.deb AS LOCAL dist/ - END + # ARG TOOLCHAIN=x86_64-unknown-linux-musl + # COPY --build-arg TOOLCHAIN=$TOOLCHAIN +rust-build/work/target/$TOOLCHAIN/release/$APP_NAME / - # SAVE ARTIFACT target/$TOOLCHAIN/release/$APP_NAME$EXT AS LOCAL dist/ - SAVE ARTIFACT target/$TOOLCHAIN/release/$APP_NAME$EXT.xz AS LOCAL dist/$APP_NAME-$TOOLCHAIN$EXT.xz + COPY ./target/x86_64-unknown-linux-musl/release/web /xpin-web + + ENV ROCKET_ADDRESS=0.0.0.0 + ENV ROCKET_PORT=8000 + ENV ROCKET_LOG_LEVEL=normal + + EXPOSE 8000 + + ENTRYPOINT ["/xpin-web"] + + SAVE IMAGE gitea.austen-wares.com/xpin/server all: BUILD +docs - BUILD +build + BUILD +rust-image