From 709f69fd8358fd3bfd249c9019a64052fd45c3dd Mon Sep 17 00:00:00 2001 From: Dermot Haughey Date: Thu, 16 Feb 2023 13:13:49 -0600 Subject: [PATCH 1/7] create reference dockerfile --- Dockerfile | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2150c2c1..65ec8f96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,31 +2,34 @@ # Cargo Build Stage # ----------------- -FROM rust:latest as cargo-build +FROM debian:latest as cargo-build -COPY . . -RUN apt-get update -RUN apt-get install -y cmake -RUN apt-get install -y clang -RUN cargo vendor > .cargo/config +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH \ + RUST_VERSION=1.67.1 -RUN cargo build --release +RUN apt-get update; \ + apt-get install -y --no-install-recommends ca-certificates curl netbase -# ----------------- -# Run Momento Proxy -# ----------------- +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init +RUN chmod +x rustup-init +RUN sh rustup-init -y --no-modify-path --profile minimal --default-toolchain stable +RUN chmod -R a+w $RUSTUP_HOME $CARGO_HOME; +RUN rustup --version; \ + cargo --version; \ + rustc --version; -FROM debian:stable-slim +# vendored cargo dependencies +COPY ./src src +COPY Cargo.lock . +COPY Cargo.toml . +# RUN mkdir .cargo +# RUN cargo vendor > .cargo/config -WORKDIR /app -ENV MOMENTO_AUTHENTICATION="" -ENV CONFIG="momento_proxy.toml" +RUN apt-get update; apt-get install -y cmake clang make protobuf-compiler -RUN mkdir config - -COPY --from=cargo-build ./target/release/momento_proxy . -COPY --from=cargo-build ./config/momento_proxy.toml ./config +RUN cargo build --release +CMD ["./target/release/pelikan_segcache_rs"] -RUN chmod +x ./momento_proxy -CMD ./momento_proxy ./config/${CONFIG} \ No newline at end of file From 0dda49d41b327613966bf6ca0c640ed4e49fc016 Mon Sep 17 00:00:00 2001 From: Dermot Haughey Date: Thu, 16 Feb 2023 13:15:52 -0600 Subject: [PATCH 2/7] rename Dockerfile to reference --- Dockerfile | 43 ++++++++++++++++++-------------------- Dockerfile.debian.segcache | 35 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 23 deletions(-) create mode 100644 Dockerfile.debian.segcache diff --git a/Dockerfile b/Dockerfile index 65ec8f96..2150c2c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,34 +2,31 @@ # Cargo Build Stage # ----------------- -FROM debian:latest as cargo-build +FROM rust:latest as cargo-build -ENV RUSTUP_HOME=/usr/local/rustup \ - CARGO_HOME=/usr/local/cargo \ - PATH=/usr/local/cargo/bin:$PATH \ - RUST_VERSION=1.67.1 +COPY . . +RUN apt-get update +RUN apt-get install -y cmake +RUN apt-get install -y clang +RUN cargo vendor > .cargo/config -RUN apt-get update; \ - apt-get install -y --no-install-recommends ca-certificates curl netbase +RUN cargo build --release -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init -RUN chmod +x rustup-init -RUN sh rustup-init -y --no-modify-path --profile minimal --default-toolchain stable -RUN chmod -R a+w $RUSTUP_HOME $CARGO_HOME; -RUN rustup --version; \ - cargo --version; \ - rustc --version; +# ----------------- +# Run Momento Proxy +# ----------------- -# vendored cargo dependencies -COPY ./src src -COPY Cargo.lock . -COPY Cargo.toml . -# RUN mkdir .cargo -# RUN cargo vendor > .cargo/config +FROM debian:stable-slim +WORKDIR /app -RUN apt-get update; apt-get install -y cmake clang make protobuf-compiler +ENV MOMENTO_AUTHENTICATION="" +ENV CONFIG="momento_proxy.toml" -RUN cargo build --release -CMD ["./target/release/pelikan_segcache_rs"] +RUN mkdir config + +COPY --from=cargo-build ./target/release/momento_proxy . +COPY --from=cargo-build ./config/momento_proxy.toml ./config +RUN chmod +x ./momento_proxy +CMD ./momento_proxy ./config/${CONFIG} \ No newline at end of file diff --git a/Dockerfile.debian.segcache b/Dockerfile.debian.segcache new file mode 100644 index 00000000..65ec8f96 --- /dev/null +++ b/Dockerfile.debian.segcache @@ -0,0 +1,35 @@ +# ----------------- +# Cargo Build Stage +# ----------------- + +FROM debian:latest as cargo-build + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH \ + RUST_VERSION=1.67.1 + +RUN apt-get update; \ + apt-get install -y --no-install-recommends ca-certificates curl netbase + +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init +RUN chmod +x rustup-init +RUN sh rustup-init -y --no-modify-path --profile minimal --default-toolchain stable +RUN chmod -R a+w $RUSTUP_HOME $CARGO_HOME; +RUN rustup --version; \ + cargo --version; \ + rustc --version; + +# vendored cargo dependencies +COPY ./src src +COPY Cargo.lock . +COPY Cargo.toml . +# RUN mkdir .cargo +# RUN cargo vendor > .cargo/config + + +RUN apt-get update; apt-get install -y cmake clang make protobuf-compiler + +RUN cargo build --release +CMD ["./target/release/pelikan_segcache_rs"] + From 8a5b1b1ac93705fe52cb3e0adb3a2771a4a0b4ac Mon Sep 17 00:00:00 2001 From: Dermot Haughey Date: Thu, 16 Feb 2023 14:24:08 -0600 Subject: [PATCH 3/7] ensure it builds --- Dockerfile.debian.segcache | 41 ++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/Dockerfile.debian.segcache b/Dockerfile.debian.segcache index 65ec8f96..b1a7af35 100644 --- a/Dockerfile.debian.segcache +++ b/Dockerfile.debian.segcache @@ -1,17 +1,25 @@ +# Reference Dockerfile for building and running Segcache from a clean slate Debian install +# +# It's recommended +# +# # ----------------- # Cargo Build Stage # ----------------- -FROM debian:latest as cargo-build +FROM debian:stable-slim as cargo-build ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ PATH=/usr/local/cargo/bin:$PATH \ RUST_VERSION=1.67.1 +# Install dependencies for Rustup RUN apt-get update; \ - apt-get install -y --no-install-recommends ca-certificates curl netbase + apt-get install -y --no-install-recommends ca-certificates curl netbase \ + && rm -rf /var/lib/apt/lists/* +# Fetch and run Rustup RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init RUN chmod +x rustup-init RUN sh rustup-init -y --no-modify-path --profile minimal --default-toolchain stable @@ -20,16 +28,33 @@ RUN rustup --version; \ cargo --version; \ rustc --version; -# vendored cargo dependencies +# Copy files necessary for build COPY ./src src +COPY ./config config COPY Cargo.lock . COPY Cargo.toml . -# RUN mkdir .cargo -# RUN cargo vendor > .cargo/config - -RUN apt-get update; apt-get install -y cmake clang make protobuf-compiler +# install build dependencies +RUN apt-get update; apt-get install -y cmake clang make protobuf-compiler \ + && rm -rf /var/lib/apt/lists/* RUN cargo build --release -CMD ["./target/release/pelikan_segcache_rs"] + + +# Run the Segcache binary + +FROM debian:stable-slim + +WORKDIR /app +RUN mkdir config + +COPY --from=cargo-build ./target/release/pelikan_segcache_rs . +COPY --from=cargo-build ./config/segcache.toml ./config + +RUN chmod +x ./pelikan_segcache_rs +CMD ./momento_proxy ./config/segcache.toml + + + +CMD ["./pelikan_segcache_rs", "./config/segcache.toml"] From edc417bb37f2f8ecfa9a3c9a3244e7b28d896d9e Mon Sep 17 00:00:00 2001 From: Dermot Haughey Date: Thu, 16 Feb 2023 14:58:13 -0600 Subject: [PATCH 4/7] Fix weird typo --- Dockerfile.debian.segcache | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Dockerfile.debian.segcache b/Dockerfile.debian.segcache index b1a7af35..95bee151 100644 --- a/Dockerfile.debian.segcache +++ b/Dockerfile.debian.segcache @@ -1,8 +1,5 @@ # Reference Dockerfile for building and running Segcache from a clean slate Debian install -# -# It's recommended -# -# + # ----------------- # Cargo Build Stage # ----------------- From bc050838dc85c9baec3f18c788be1f2b928f4bbe Mon Sep 17 00:00:00 2001 From: Dermot Haughey Date: Thu, 16 Feb 2023 15:01:13 -0600 Subject: [PATCH 5/7] Add clarification to reference dockerfile Explain the rationale behind the dockerfile being built from such a minimal base --- Dockerfile.debian.segcache | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile.debian.segcache b/Dockerfile.debian.segcache index 95bee151..8ec9c202 100644 --- a/Dockerfile.debian.segcache +++ b/Dockerfile.debian.segcache @@ -1,5 +1,10 @@ # Reference Dockerfile for building and running Segcache from a clean slate Debian install - +# +# Note: using `rust:latest` in FROM will save a lot of the effort of installing Rust but will also bring along many packages from `buildpack-deps` or otherwise +# we've created this Dockerfile from `debian:stable-slim` to make a best attempt at demonstrating the list of packages one would need if starting from +# a minimal installation for the purpose of informing developers of Pelikan. +# +# # ----------------- # Cargo Build Stage # ----------------- From ec51092d5e7af731b0d575edf1a8bb000f567435 Mon Sep 17 00:00:00 2001 From: Dermot Haughey Date: Sat, 18 Feb 2023 11:27:40 -0600 Subject: [PATCH 6/7] remove conflicting CMD line --- Dockerfile.debian.segcache | 3 --- 1 file changed, 3 deletions(-) diff --git a/Dockerfile.debian.segcache b/Dockerfile.debian.segcache index 8ec9c202..460e9d99 100644 --- a/Dockerfile.debian.segcache +++ b/Dockerfile.debian.segcache @@ -54,9 +54,6 @@ COPY --from=cargo-build ./target/release/pelikan_segcache_rs . COPY --from=cargo-build ./config/segcache.toml ./config RUN chmod +x ./pelikan_segcache_rs -CMD ./momento_proxy ./config/segcache.toml - - CMD ["./pelikan_segcache_rs", "./config/segcache.toml"] From a8cbe7d474bd14ffed5cb72c6644bf1bc1823cdb Mon Sep 17 00:00:00 2001 From: Dermot Haughey Date: Sat, 18 Feb 2023 11:29:01 -0600 Subject: [PATCH 7/7] 80 chars linewidth --- Dockerfile.debian.segcache | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile.debian.segcache b/Dockerfile.debian.segcache index 460e9d99..16329591 100644 --- a/Dockerfile.debian.segcache +++ b/Dockerfile.debian.segcache @@ -1,9 +1,10 @@ # Reference Dockerfile for building and running Segcache from a clean slate Debian install # -# Note: using `rust:latest` in FROM will save a lot of the effort of installing Rust but will also bring along many packages from `buildpack-deps` or otherwise -# we've created this Dockerfile from `debian:stable-slim` to make a best attempt at demonstrating the list of packages one would need if starting from -# a minimal installation for the purpose of informing developers of Pelikan. -# +# Note: using `rust:latest` in FROM will save a lot of the effort of installing Rust +# but will also bring along many packages from `buildpack-deps` or otherwise +# we've created this Dockerfile from `debian:stable-slim` to make a best attempt +# at demonstrating the list of packages one would need if starting from a minimal installation +# for the purpose of informing developers of Pelikan. # # ----------------- # Cargo Build Stage