2023-03-28 22:39:13 +03:00
|
|
|
FROM rust:1.68.2-bullseye AS builder
|
2022-04-23 21:00:03 +03:00
|
|
|
|
2023-01-31 00:53:58 +03:00
|
|
|
WORKDIR /app
|
2023-02-08 22:14:30 +03:00
|
|
|
ENV CARGO_TERM_COLOR always
|
2023-01-31 00:53:58 +03:00
|
|
|
|
|
|
|
# a next-generation test runner for Rust projects.
|
2023-03-28 22:39:13 +03:00
|
|
|
# We only pay the installation cost once,
|
|
|
|
# it will be cached from the second build onwards
|
2023-01-31 01:51:37 +03:00
|
|
|
# TODO: more mount type cache?
|
2023-03-28 22:39:13 +03:00
|
|
|
# TODO: do this in a seperate FROM and COPY it in
|
2023-01-31 00:53:58 +03:00
|
|
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
2023-01-31 01:51:37 +03:00
|
|
|
cargo install cargo-nextest
|
2023-01-31 00:53:58 +03:00
|
|
|
|
|
|
|
# foundry is needed to run tests
|
2023-03-03 13:54:52 +03:00
|
|
|
# TODO: do this in a seperate FROM and COPY it in
|
2022-12-15 06:25:57 +03:00
|
|
|
ENV PATH /root/.foundry/bin:$PATH
|
|
|
|
RUN curl -L https://foundry.paradigm.xyz | bash && foundryup
|
|
|
|
|
2023-03-28 22:39:13 +03:00
|
|
|
# install web3-proxy system dependencies. most things are rust-only, but not everything
|
|
|
|
RUN apt-get update && \
|
2023-04-20 01:22:27 +03:00
|
|
|
apt-get install --yes \
|
|
|
|
cmake \
|
|
|
|
liblz4-dev \
|
|
|
|
libpthread-stubs0-dev \
|
2023-04-21 00:48:15 +03:00
|
|
|
libsasl2-dev \
|
2023-04-20 01:22:27 +03:00
|
|
|
libssl-dev \
|
|
|
|
libzstd-dev \
|
|
|
|
make \
|
|
|
|
&& \
|
2023-03-28 22:39:13 +03:00
|
|
|
rm -rf /var/lib/apt/lists/*
|
2023-03-03 04:39:50 +03:00
|
|
|
|
2023-01-31 00:53:58 +03:00
|
|
|
# copy the application
|
2022-04-23 21:00:03 +03:00
|
|
|
COPY . .
|
2023-01-31 00:53:58 +03:00
|
|
|
|
|
|
|
# test the application with cargo-nextest
|
2022-04-23 21:00:03 +03:00
|
|
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
2023-01-31 00:53:58 +03:00
|
|
|
--mount=type=cache,target=/app/target \
|
|
|
|
cargo nextest run
|
2022-04-23 21:00:03 +03:00
|
|
|
|
2023-01-31 00:53:58 +03:00
|
|
|
# build the application
|
2023-02-03 00:55:48 +03:00
|
|
|
# using a "release" profile (which install does) is **very** important
|
2023-01-31 00:53:58 +03:00
|
|
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
|
|
|
--mount=type=cache,target=/app/target \
|
2023-03-01 21:53:56 +03:00
|
|
|
cargo install \
|
2023-01-26 08:24:09 +03:00
|
|
|
--features tokio-uring \
|
2023-03-01 21:53:56 +03:00
|
|
|
--locked \
|
2023-04-20 01:22:27 +03:00
|
|
|
--features rdkafka-src \
|
2023-03-01 21:53:56 +03:00
|
|
|
--no-default-features \
|
2023-01-26 08:24:09 +03:00
|
|
|
--path ./web3_proxy \
|
2023-03-01 21:53:56 +03:00
|
|
|
--profile faster_release \
|
2023-04-05 22:30:44 +03:00
|
|
|
--root /usr/local/bin
|
2022-05-06 04:25:49 +03:00
|
|
|
|
2023-01-31 00:53:58 +03:00
|
|
|
#
|
|
|
|
# We do not need the Rust toolchain to run the binary!
|
|
|
|
#
|
|
|
|
FROM debian:bullseye-slim AS runtime
|
2023-01-18 08:26:10 +03:00
|
|
|
|
2023-02-07 00:46:45 +03:00
|
|
|
# Create llama user to avoid running container with root
|
|
|
|
RUN mkdir /llama \
|
|
|
|
&& adduser --home /llama --shell /sbin/nologin --gecos '' --no-create-home --disabled-password --uid 1001 llama \
|
|
|
|
&& chown -R llama /llama
|
|
|
|
|
|
|
|
USER llama
|
|
|
|
|
2023-01-19 13:30:58 +03:00
|
|
|
ENTRYPOINT ["web3_proxy_cli"]
|
2023-01-19 13:32:24 +03:00
|
|
|
CMD [ "--config", "/web3-proxy.toml", "proxyd" ]
|
2022-05-12 22:58:26 +03:00
|
|
|
|
|
|
|
# TODO: lower log level when done with prototyping
|
2023-04-19 06:50:35 +03:00
|
|
|
ENV RUST_LOG "warn,ethers_providers::rpc=off,web3_proxy=debug,web3_proxy_cli=debug"
|
2023-01-31 00:53:58 +03:00
|
|
|
|
2023-04-05 22:30:44 +03:00
|
|
|
COPY --from=builder /usr/local/bin/* /usr/local/bin/
|