-
Notifications
You must be signed in to change notification settings - Fork 5
/
ingester.Dockerfile
64 lines (56 loc) · 2.54 KB
/
ingester.Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Initial stage: install cargo-chef
FROM rust:1.76-bullseye AS chef
RUN cargo install cargo-chef
# Planning stage: determine dependencies
FROM chef AS planner
WORKDIR /rust
COPY Cargo.toml Cargo.toml
COPY Cargo.lock Cargo.lock
COPY backfill_rpc ./backfill_rpc
COPY entities ./entities
COPY grpc ./grpc
COPY interface ./interface
COPY metrics_utils ./metrics_utils
COPY nft_ingester ./nft_ingester
COPY postgre-client ./postgre-client
COPY rocks-db ./rocks-db
COPY tests/setup ./tests/setup
COPY usecase ./usecase
COPY integrity_verification ./integrity_verification
RUN cargo chef prepare --recipe-path recipe.json
# Caching dependencies
FROM chef AS cacher
WORKDIR /rust
RUN apt update && apt install -y libclang-dev protobuf-compiler
RUN wget https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2 && \
tar -xjf jemalloc-5.3.0.tar.bz2 && \
cd jemalloc-5.3.0 && \
./configure --enable-prof --enable-stats --enable-debug --enable-fill && \
make && make install
COPY --from=planner /rust/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# Building the services
FROM cacher AS builder
COPY . .
RUN cargo build --release --bin ingester --bin api --bin raw_backfiller --bin synchronizer
# Building the profiling feature services
FROM cacher AS builder-with-profiling
COPY . .
RUN cargo build --release --features profiling --bin ingester --bin api --bin raw_backfiller --bin synchronizer
# Final image
FROM rust:1.76-slim-bullseye AS runtime
ARG APP=/usr/src/app
RUN apt update && apt install -y curl ca-certificates tzdata libjemalloc2 google-perftools graphviz libjemalloc-dev && rm -rf /var/lib/apt/lists/*
COPY --from=cacher /usr/local/lib/libjemalloc.so.2 /usr/local/lib/libjemalloc.so.2
ENV TZ=Etc/UTC APP_USER=appuser LD_PRELOAD="/usr/local/lib/libjemalloc.so.2"
RUN groupadd $APP_USER && useradd -g $APP_USER $APP_USER && mkdir -p ${APP}
COPY --from=builder /rust/target/release/ingester ${APP}/ingester
COPY --from=builder /rust/target/release/raw_backfiller ${APP}/raw_backfiller
COPY --from=builder /rust/target/release/api ${APP}/api
COPY --from=builder /rust/target/release/synchronizer ${APP}/synchronizer
COPY --from=builder-with-profiling /rust/target/release/ingester ${APP}/profiling_ingester
COPY --from=builder-with-profiling /rust/target/release/raw_backfiller ${APP}/profiling_raw_backfiller
COPY --from=builder-with-profiling /rust/target/release/api ${APP}/profiling_api
COPY --from=builder-with-profiling /rust/target/release/synchronizer ${APP}/profiling_synchronizer
WORKDIR ${APP}
STOPSIGNAL SIGINT