From a09c70f7dc82220340b5c3af2b0e0b377b56d731 Mon Sep 17 00:00:00 2001 From: Ali Behjati Date: Thu, 9 Jan 2025 13:45:31 +0100 Subject: [PATCH 1/3] refactor(docker): use minimal docker for image publish --- .github/workflows/rust.yaml | 2 +- Cargo.lock | 2 +- Cargo.toml | 2 +- Dockerfile | 26 +++++++++++--------------- agent.Dockerfile | 17 ----------------- 5 files changed, 14 insertions(+), 35 deletions(-) delete mode 100644 agent.Dockerfile diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index e6311552..b37156a8 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -16,6 +16,6 @@ jobs: - name: Check-out code uses: actions/checkout@v2 - name: Build image - run: docker build -t agent . + run: docker build -f integration-tests/Dockerfile -t agent . - name: Run tests run: docker run -v $PWD:/agent agent ./tests.sh diff --git a/Cargo.lock b/Cargo.lock index 4f5de11d..f49e94e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3400,7 +3400,7 @@ dependencies = [ [[package]] name = "pyth-agent" -version = "2.12.0" +version = "2.12.1" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 6ef86430..1393f690 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyth-agent" -version = "2.12.0" +version = "2.12.1" edition = "2021" [[bin]] diff --git a/Dockerfile b/Dockerfile index d674e641..08cc7132 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,17 @@ -FROM python:3.10-slim-bullseye +FROM rust:slim-bookworm as builder -# Install Rust -RUN apt update && apt install -y curl pkg-config libssl-dev build-essential -RUN curl https://sh.rustup.rs -sSf | bash -s -- -y -ENV PATH="/root/.cargo/bin:${PATH}" -RUN rustup toolchain install nightly - -# Install poetry -RUN pip install poetry -ENV PATH="${PATH}:/root/.local/bin" -RUN poetry config virtualenvs.in-project true - -# Install Solana Tool Suite -RUN sh -c "$(curl -sSfL https://release.solana.com/v1.14.17/install)" -ENV PATH="${PATH}:/root/.local/share/solana/install/active_release/bin" +RUN apt update && apt install -y curl libssl-dev pkg-config && apt clean all ADD . /agent WORKDIR /agent RUN cargo build --release + +FROM debian:12-slim + +RUN apt update && apt install -y libssl-dev && apt clean all + +COPY --from=builder /agent/target/release/agent /agent/ +COPY --from=builder /agent/config/* /agent/config/ + +ENTRYPOINT ["/agent/agent"] diff --git a/agent.Dockerfile b/agent.Dockerfile deleted file mode 100644 index 08cc7132..00000000 --- a/agent.Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM rust:slim-bookworm as builder - -RUN apt update && apt install -y curl libssl-dev pkg-config && apt clean all - -ADD . /agent -WORKDIR /agent - -RUN cargo build --release - -FROM debian:12-slim - -RUN apt update && apt install -y libssl-dev && apt clean all - -COPY --from=builder /agent/target/release/agent /agent/ -COPY --from=builder /agent/config/* /agent/config/ - -ENTRYPOINT ["/agent/agent"] From 9bedf008dad1eeb76bad282e7a0701439c2b99ee Mon Sep 17 00:00:00 2001 From: Ali Behjati Date: Thu, 9 Jan 2025 13:47:20 +0100 Subject: [PATCH 2/3] update readme to add dockerfile taken from #148 --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9eaf2e0f..92abae27 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,19 @@ through the `RUST_LOG` environment variable using the standard Pyth agent will print logs in plaintext in terminal and JSON format in non-terminal environments (e.g. when writing to a file). ## Run -`cargo run --release -- --config ` will build and run the agent in a single step. +### From Source +The preferred way to run Pyth Agent is by compiling from source. You can run the below command to build and run the agent in a single step. + +```bash +cargo run --release -- --config +``` + +### Container +For convenience, a minimal container image is also published to [ECR Public](https://gallery.ecr.aws/pyth-network/agent). An example command for running this container can be found below. Make sure to update the image version to the latest release of Pyth Agent. + +```bash +docker run -v /path/to/configdir:/config:z,ro public.ecr.aws/pyth-network/agent:v2.12.0-minimal +``` ## Publishing API A running agent will expose a WebSocket serving the JRPC publishing API documented [here](https://docs.pyth.network/documentation/publish-data/pyth-client-websocket-api). See `config/config.toml` for related settings. From 2d1406678d8f7ceaf588032baf003378f8786f47 Mon Sep 17 00:00:00 2001 From: Ali Behjati Date: Thu, 9 Jan 2025 13:48:07 +0100 Subject: [PATCH 3/3] add skipped dockerfile --- integration-tests/Dockerfile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 integration-tests/Dockerfile diff --git a/integration-tests/Dockerfile b/integration-tests/Dockerfile new file mode 100644 index 00000000..d674e641 --- /dev/null +++ b/integration-tests/Dockerfile @@ -0,0 +1,21 @@ +FROM python:3.10-slim-bullseye + +# Install Rust +RUN apt update && apt install -y curl pkg-config libssl-dev build-essential +RUN curl https://sh.rustup.rs -sSf | bash -s -- -y +ENV PATH="/root/.cargo/bin:${PATH}" +RUN rustup toolchain install nightly + +# Install poetry +RUN pip install poetry +ENV PATH="${PATH}:/root/.local/bin" +RUN poetry config virtualenvs.in-project true + +# Install Solana Tool Suite +RUN sh -c "$(curl -sSfL https://release.solana.com/v1.14.17/install)" +ENV PATH="${PATH}:/root/.local/share/solana/install/active_release/bin" + +ADD . /agent +WORKDIR /agent + +RUN cargo build --release