From 0948f75248a5daf8229ce1f40d1b3ec8d9aecbac Mon Sep 17 00:00:00 2001 From: fx Date: Sun, 15 Oct 2023 02:26:29 +0200 Subject: test w/ cargo chef + arm64 --- .github/workflows/test.yml | 7 +++---- Dockerfile | 27 +++++++++++++++++++++++---- Dockerfile.arm.build | 16 ---------------- Dockerfile.build | 18 ------------------ build.rs.disabled | 5 +++++ nobuild.rs.old | 5 ----- 6 files changed, 31 insertions(+), 47 deletions(-) delete mode 100644 Dockerfile.arm.build delete mode 100644 Dockerfile.build create mode 100644 build.rs.disabled delete mode 100644 nobuild.rs.old diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ed9fba6..649f295 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -51,9 +51,8 @@ jobs: id: docker_build uses: docker/build-push-action@v3 with: - file: Dockerfile.build push: true - platforms: linux/amd64,linux/arm/v7 + platforms: linux/amd64,linux/arm64 tags: | - ghcr.io/fxqnlr/webol:test-latest - ghcr.io/fxqnlr/webol:test-${{ github.run_number }} + ghcr.io/fxqnlr/webol:latest + ghcr.io/fxqnlr/webol:${{ github.run_number }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index d014c5a..5757f0d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,26 @@ -FROM --platform=amd64 debian:bullseye-slim +FROM debian:bookworm AS deb_extractor +RUN cd /tmp && \ + apt-get update && apt-get download \ + libc6 && \ + mkdir /dpkg && \ + for deb in *.deb; do dpkg --extract $deb /dpkg || exit 10; done -WORKDIR /usr/local/webol -COPY target/armv7-unknown-linux-gnueabihf/release/webol /usr/local/bin/webol +FROM lukemathwalker/cargo-chef:latest-rust-1.73.0 as chef +WORKDIR app + +FROM chef AS planner +COPY . . +RUN cargo chef prepare --recipe-path recipe.json + +FROM chef as builder +COPY --from=planner /app/recipe.json recipe.json +RUN cargo chef cook --release --recipe-path recipe.json +COPY . . +RUN cargo build --release + +FROM gcr.io/distroless/cc +COPY --from=builder /app/target/release/webol / +COPY --from=deb_extractor /dpkg / EXPOSE 7229 -CMD ["webol"] \ No newline at end of file +ENTRYPOINT ["./webol"] diff --git a/Dockerfile.arm.build b/Dockerfile.arm.build deleted file mode 100644 index 1845afe..0000000 --- a/Dockerfile.arm.build +++ /dev/null @@ -1,16 +0,0 @@ -FROM rust:1.73 as builder -WORKDIR /usr/src/webol -COPY . . -#RUN rustup target add armv7-unknown-linux-gnueabihf -#RUN apt update && apt install gcc-arm-linux-gnueabihf -y -#RUN CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc cargo install --path . --target armv7-unknown-linux-gnueabihf -RUN cargo install --path . - -#FROM --platform=arm64 debian:bookworm-slim -FROM debian:bookworm-slim -RUN apt update && apt install -y libc6 && rm -rf /var/lib/apt/lists/* -WORKDIR /usr/local/webol -COPY --from=builder /usr/local/cargo/bin/webol /usr/local/bin/webol - -EXPOSE 7229 -CMD ["webol"] diff --git a/Dockerfile.build b/Dockerfile.build deleted file mode 100644 index 0158b8a..0000000 --- a/Dockerfile.build +++ /dev/null @@ -1,18 +0,0 @@ -FROM debian:bookworm AS deb_extractor -RUN cd /tmp && \ - apt-get update && apt-get download \ - libc6 && \ - mkdir /dpkg && \ - for deb in *.deb; do dpkg --extract $deb /dpkg || exit 10; done - -FROM rust:1.73 as builder -WORKDIR /app -COPY . . -RUN cargo build --release - -FROM gcr.io/distroless/cc -COPY --from=builder /app/target/release/webol / -COPY --from=deb_extractor /dpkg / - -EXPOSE 7229 -ENTRYPOINT ["./webol"] diff --git a/build.rs.disabled b/build.rs.disabled new file mode 100644 index 0000000..7609593 --- /dev/null +++ b/build.rs.disabled @@ -0,0 +1,5 @@ +// generated by `sqlx migrate build-script` +fn main() { + // trigger recompilation when a new migration is added + println!("cargo:rerun-if-changed=migrations"); +} \ No newline at end of file diff --git a/nobuild.rs.old b/nobuild.rs.old deleted file mode 100644 index 7609593..0000000 --- a/nobuild.rs.old +++ /dev/null @@ -1,5 +0,0 @@ -// generated by `sqlx migrate build-script` -fn main() { - // trigger recompilation when a new migration is added - println!("cargo:rerun-if-changed=migrations"); -} \ No newline at end of file -- cgit v1.2.3