From 1ca45344eb71c5a15272437aa6b9f8d507d29c45 Mon Sep 17 00:00:00 2001 From: Michael Danenberg <56533526+danenbm@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:37:54 -0800 Subject: [PATCH] Fixing docker files to work with workspace (#164) * Fixing docker files to work with workspace * Comment out cargo chef cook for ingester and api --- Api.Dockerfile | 34 +++++++++++++++++++++++++++------- Ingest.Dockerfile | 34 +++++++++++++++++++++++++++------- Load.Dockerfile | 41 ++++++++++++++++++++++++++++++----------- Migrator.Dockerfile | 15 +++++++++++---- Proxy.Dockerfile | 11 ++++++++++- 5 files changed, 105 insertions(+), 30 deletions(-) diff --git a/Api.Dockerfile b/Api.Dockerfile index c722f341a..e52a0c220 100644 --- a/Api.Dockerfile +++ b/Api.Dockerfile @@ -1,21 +1,41 @@ FROM rust:1.73-bullseye AS chef RUN cargo install cargo-chef FROM chef AS planner -COPY das_api /rust/das_api/ + +RUN mkdir /rust +COPY Cargo.toml /rust +COPY das_api /rust/das_api +COPY digital_asset_types /rust/digital_asset_types +COPY metaplex-rpc-proxy /rust/metaplex-rpc-proxy +COPY migration /rust/migration +COPY nft_ingester /rust/nft_ingester +COPY tools /rust/tools + WORKDIR /rust/das_api -RUN cargo chef prepare --recipe-path recipe.json +RUN cargo chef prepare --recipe-path /rust/das_api/recipe.json FROM chef AS builder RUN apt-get update -y && \ apt-get install -y build-essential make git + +RUN mkdir /rust +COPY Cargo.toml /rust +COPY das_api /rust/das_api COPY digital_asset_types /rust/digital_asset_types -WORKDIR / -RUN mkdir -p /rust/das_api +COPY metaplex-rpc-proxy /rust/metaplex-rpc-proxy +COPY migration /rust/migration +COPY nft_ingester /rust/nft_ingester +COPY tools /rust/tools + WORKDIR /rust/das_api COPY --from=planner /rust/das_api/recipe.json recipe.json + # Build dependencies - this is the caching Docker layer! -COPY das_api/Cargo.toml . -COPY das_api . +# TODO: Fix this. For now we are building without the cached dependencies as there's apparently +# some problem with digital-asset-types feature activation. + +# RUN cargo chef cook --release --recipe-path recipe.json --target-dir /rust/target --all-features + # Build application RUN cargo build --release @@ -29,7 +49,7 @@ ENV TZ=Etc/UTC \ RUN groupadd $APP_USER \ && useradd -g $APP_USER $APP_USER \ && mkdir -p ${APP} -COPY --from=builder /rust/das_api/target/release/das_api ${APP} +COPY --from=builder /rust/target/release/das_api ${APP} RUN chown -R $APP_USER:$APP_USER ${APP} USER $APP_USER WORKDIR ${APP} diff --git a/Ingest.Dockerfile b/Ingest.Dockerfile index 20db79edd..7597f24c4 100644 --- a/Ingest.Dockerfile +++ b/Ingest.Dockerfile @@ -1,21 +1,41 @@ FROM rust:1.73-bullseye AS chef RUN cargo install cargo-chef FROM chef AS planner -COPY nft_ingester /rust/nft_ingester/ + +RUN mkdir /rust +COPY Cargo.toml /rust +COPY das_api /rust/das_api +COPY digital_asset_types /rust/digital_asset_types +COPY metaplex-rpc-proxy /rust/metaplex-rpc-proxy +COPY migration /rust/migration +COPY nft_ingester /rust/nft_ingester +COPY tools /rust/tools + WORKDIR /rust/nft_ingester -RUN cargo chef prepare --recipe-path recipe.json +RUN cargo chef prepare --recipe-path /rust/nft_ingester/recipe.json FROM chef AS builder RUN apt-get update -y && \ apt-get install -y build-essential make git + +RUN mkdir /rust +COPY Cargo.toml /rust +COPY das_api /rust/das_api COPY digital_asset_types /rust/digital_asset_types -WORKDIR / -RUN mkdir -p /rust/nft_ingester +COPY metaplex-rpc-proxy /rust/metaplex-rpc-proxy +COPY migration /rust/migration +COPY nft_ingester /rust/nft_ingester +COPY tools /rust/tools + WORKDIR /rust/nft_ingester COPY --from=planner /rust/nft_ingester/recipe.json recipe.json + # Build dependencies - this is the caching Docker layer! -COPY nft_ingester/Cargo.toml . -COPY nft_ingester . +# TODO: Fix this. For now we are building without the cached dependencies as there's apparently +# some problem with digital-asset-types feature activation. + +# RUN cargo chef cook --release --recipe-path recipe.json --target-dir /rust/target --all-features + # Build application RUN cargo build --release @@ -29,7 +49,7 @@ ENV TZ=Etc/UTC \ RUN groupadd $APP_USER \ && useradd -g $APP_USER $APP_USER \ && mkdir -p ${APP} -COPY --from=builder /rust/nft_ingester/target/release/nft_ingester ${APP} +COPY --from=builder /rust/target/release/nft_ingester ${APP} RUN chown -R $APP_USER:$APP_USER ${APP} USER $APP_USER WORKDIR ${APP} diff --git a/Load.Dockerfile b/Load.Dockerfile index 9ec3aacc4..e256cacf7 100644 --- a/Load.Dockerfile +++ b/Load.Dockerfile @@ -1,22 +1,41 @@ FROM rust:1.73-bullseye AS chef RUN cargo install cargo-chef FROM chef AS planner -COPY tools/load_generation /rust/load_generation/ -WORKDIR /rust/load_generation -RUN cargo chef prepare --recipe-path recipe.json + +RUN mkdir /rust +COPY Cargo.toml /rust +COPY das_api /rust/das_api +COPY digital_asset_types /rust/digital_asset_types +COPY metaplex-rpc-proxy /rust/metaplex-rpc-proxy +COPY migration /rust/migration +COPY nft_ingester /rust/nft_ingester +COPY tools /rust/tools + +WORKDIR /rust/tools/load_generation +RUN cargo chef prepare --recipe-path /rust/tools/load_generation/recipe.json + FROM chef AS builder RUN apt-get update -y && \ apt-get install -y build-essential make git -COPY tools/load_generation /rust/load_generation -RUN mkdir -p /rust/load_generation -WORKDIR /rust/load_generation -COPY --from=planner /rust/load_generation/recipe.json recipe.json + +RUN mkdir /rust +COPY Cargo.toml /rust +COPY das_api /rust/das_api +COPY digital_asset_types /rust/digital_asset_types +COPY metaplex-rpc-proxy /rust/metaplex-rpc-proxy +COPY migration /rust/migration +COPY nft_ingester /rust/nft_ingester +COPY tools /rust/tools + +WORKDIR /rust/tools/load_generation +COPY --from=planner /rust/tools/load_generation/recipe.json recipe.json + # Build dependencies - this is the caching Docker layer! -COPY tools/load_generation/Cargo.toml . -RUN cargo chef cook --release --recipe-path recipe.json -COPY tools/load_generation . +RUN cargo chef cook --release --recipe-path recipe.json --target-dir /rust/target + # Build application RUN cargo build --release + FROM rust:1.73-slim-bullseye ARG APP=/usr/src/app RUN apt update \ @@ -27,7 +46,7 @@ ENV TZ=Etc/UTC \ RUN groupadd $APP_USER \ && useradd -g $APP_USER $APP_USER \ && mkdir -p ${APP} -COPY --from=builder /rust/load_generation/target/release/load_generation ${APP} +COPY --from=builder /rust/target/release/load_generation ${APP} RUN chown -R $APP_USER:$APP_USER ${APP} USER $APP_USER WORKDIR ${APP} diff --git a/Migrator.Dockerfile b/Migrator.Dockerfile index e8588c14e..ac83e4945 100644 --- a/Migrator.Dockerfile +++ b/Migrator.Dockerfile @@ -1,9 +1,16 @@ FROM rust:1.73-bullseye COPY init.sql /init.sql -COPY migration /migration ENV INIT_FILE_PATH=/init.sql -COPY digital_asset_types /digital_asset_types + +COPY Cargo.toml / +COPY ./das_api /das_api +COPY ./digital_asset_types /digital_asset_types +COPY ./metaplex-rpc-proxy /metaplex-rpc-proxy +COPY ./migration /migration +COPY ./nft_ingester /nft_ingester +COPY ./tools /tools + WORKDIR /migration RUN cargo build --release -WORKDIR /migration/target/release -CMD /migration/target/release/migration up -n 100 +WORKDIR /target/release +CMD /target/release/migration up -n 100 \ No newline at end of file diff --git a/Proxy.Dockerfile b/Proxy.Dockerfile index 224a721e8..73c01fcf5 100644 --- a/Proxy.Dockerfile +++ b/Proxy.Dockerfile @@ -1,10 +1,19 @@ FROM rust:1.73-bullseye AS builder + +RUN mkdir /rust +COPY ./Cargo.toml /rust +COPY ./das_api /rust/das_api +COPY ./digital_asset_types /rust/digital_asset_types COPY ./metaplex-rpc-proxy /rust/metaplex-rpc-proxy +COPY ./migration /rust/migration +COPY ./nft_ingester /rust/nft_ingester +COPY ./tools /rust/tools + WORKDIR /rust/metaplex-rpc-proxy RUN cargo install wasm-pack RUN wasm-pack build --release FROM envoyproxy/envoy:v1.24.0 -COPY --from=builder /rust/metaplex-rpc-proxy/target/wasm32-unknown-unknown/release/metaplex_rpc_proxy.wasm /etc/rpc_proxy.wasm +COPY --from=builder /rust/target/wasm32-unknown-unknown/release/metaplex_rpc_proxy.wasm /etc/rpc_proxy.wasm RUN apt-get update && apt-get install -y ca-certificates ENTRYPOINT /usr/local/bin/envoy -c /etc/envoy.yaml -l trace --service-cluster proxy