From 95227aa296008d70fac0a42311af0e6c25068e71 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Sun, 2 Oct 2022 16:07:14 -0400 Subject: [PATCH] Convert containerfile to two-stage build + app --- Containerfile | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Containerfile b/Containerfile index b8a2534..9f16edc 100644 --- a/Containerfile +++ b/Containerfile @@ -1,22 +1,24 @@ # Use unstable for the moment, since this requires rustc >= 1.61 -FROM docker.io/library/debian:unstable-slim +FROM docker.io/library/debian:unstable-slim as build +ARG BUILD_ARGS +ENV BUILD_ARGS=${BUILD_ARGS:---release} RUN apt-get update RUN apt-get install -y pkg-config build-essential RUN apt-get install -y cargo RUN apt-get install -y libssl-dev RUN mkdir -p /src -RUN mkdir -p /var/lib/haunter -RUN mkdir -p /etc/haunter WORKDIR /src COPY ./src ./src COPY ./Cargo.toml ./ COPY ./Cargo.lock ./ -RUN cargo build --release -RUN cp target/release/haunter /usr/local/bin/haunter +RUN cargo build ${BUILD_ARGS} + + +FROM docker.io/library/debian:unstable-slim as main +RUN apt-get update +RUN apt-get install -y libssl3 +RUN mkdir -p /var/lib/haunter +RUN mkdir -p /etc/haunter WORKDIR /var/lib/haunter -RUN rm -rf /src -# Other cleanup -RUN apt-get purge cargo pkg-config build-essential -y -RUN apt-get autoremove --purge -y -RUN apt-get clean +COPY --from=build /src/target/release/haunter /usr/local/bin/haunter CMD /usr/local/bin/haunter \ No newline at end of file