Skip to content

Commit

Permalink
Fixing docker files to work with workspace (#164)
Browse files Browse the repository at this point in the history
* Fixing docker files to work with workspace

* Comment out cargo chef cook for ingester and api
  • Loading branch information
danenbm authored Jan 24, 2024
1 parent 5d0177a commit 1ca4534
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 30 deletions.
34 changes: 27 additions & 7 deletions Api.Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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}
Expand Down
34 changes: 27 additions & 7 deletions Ingest.Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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}
Expand Down
41 changes: 30 additions & 11 deletions Load.Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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}
Expand Down
15 changes: 11 additions & 4 deletions Migrator.Dockerfile
Original file line number Diff line number Diff line change
@@ -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
11 changes: 10 additions & 1 deletion Proxy.Dockerfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1ca4534

Please sign in to comment.