build(docker): add Dockerfile and builder
Some checks failed
ci/woodpecker/push/build Pipeline failed
ci/woodpecker/push/todo-check Pipeline was successful
ci/woodpecker/push/release Pipeline was successful
ci/woodpecker/push/docker Pipeline failed
ci/woodpecker/manual/build Pipeline failed
ci/woodpecker/manual/release Pipeline was successful
ci/woodpecker/manual/docker Pipeline was successful
ci/woodpecker/manual/todo-check Pipeline was successful
ci/woodpecker/cron/release Pipeline was successful
ci/woodpecker/cron/todo-check Pipeline failed
ci/woodpecker/cron/docker Pipeline was successful
ci/woodpecker/cron/build Pipeline was successful
Some checks failed
ci/woodpecker/push/build Pipeline failed
ci/woodpecker/push/todo-check Pipeline was successful
ci/woodpecker/push/release Pipeline was successful
ci/woodpecker/push/docker Pipeline failed
ci/woodpecker/manual/build Pipeline failed
ci/woodpecker/manual/release Pipeline was successful
ci/woodpecker/manual/docker Pipeline was successful
ci/woodpecker/manual/todo-check Pipeline was successful
ci/woodpecker/cron/release Pipeline was successful
ci/woodpecker/cron/todo-check Pipeline failed
ci/woodpecker/cron/docker Pipeline was successful
ci/woodpecker/cron/build Pipeline was successful
This commit is contained in:
parent
a3c52c7761
commit
b5a1dd4326
2 changed files with 56 additions and 0 deletions
33
Dockerfile
Normal file
33
Dockerfile
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Leveraging the pre-built Docker images with
|
||||
# cargo-chef and the Rust toolchain
|
||||
FROM git.kemitix.net/kemitix/git-next-builder:latest AS builder
|
||||
WORKDIR /app
|
||||
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY src src
|
||||
RUN cargo chef prepare --recipe-path recipe.json
|
||||
|
||||
ARG CARGO_PROFILE
|
||||
# Build dependencies - this is the caching Docker layer!
|
||||
RUN cargo chef cook --profile "$CARGO_PROFILE" --recipe-path recipe.json
|
||||
# Build application
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY src src
|
||||
ARG CARGO_PROFILE
|
||||
RUN cargo build --profile "$CARGO_PROFILE" --bin git-next
|
||||
RUN if test "$CARGO_PROFILE" == "release" ; then strip target/release/git-next ; fi
|
||||
|
||||
# We do not need the Rust toolchain to run the binary!
|
||||
FROM docker.io/debian:stable-20240211-slim AS runtime
|
||||
WORKDIR /app
|
||||
RUN apt-get update && \
|
||||
apt-get install --no-install-recommends -y \
|
||||
libssl3=3.0.11-1~deb12u2 \
|
||||
ca-certificates=20230311 \
|
||||
&& \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
USER 1000
|
||||
|
||||
ARG CARGO_TARGET
|
||||
COPY --from=builder /app/target/"$CARGO_TARGET"/git-next /usr/local/bin
|
||||
ENTRYPOINT [ "/usr/local/bin/git-next" ]
|
23
Dockerfile.builder
Normal file
23
Dockerfile.builder
Normal file
|
@ -0,0 +1,23 @@
|
|||
FROM docker.io/rust:latest
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y clang-15 mold && \
|
||||
curl -L https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz -o cargo-binstall.tgz && \
|
||||
tar -xzf cargo-binstall.tgz && \
|
||||
rm cargo-binstall.tgz && \
|
||||
mv cargo-binstall /usr/local/bin/ && \
|
||||
cargo binstall -y cargo-chef && \
|
||||
rustup component add rustfmt clippy
|
||||
|
||||
# verify that the binaries are installed
|
||||
RUN ls -l /usr/local/cargo/bin/
|
||||
RUN cargo chef --version
|
||||
RUN rustfmt --version
|
||||
RUN cargo fmt --version
|
||||
RUN cargo clippy --version
|
||||
RUN mold --version
|
||||
RUN clang-15 --version
|
||||
RUN cargo --version
|
||||
RUN rustc --version
|
||||
RUN rustup --version
|
||||
RUN rustup show
|
Loading…
Reference in a new issue