Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(docker): use minimal docker for image publish #149

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyth-agent"
version = "2.12.0"
version = "2.12.1"
edition = "2021"

[[bin]]
Expand Down
26 changes: 11 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <your_config.toml>` 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 <your_config.toml>
```

### 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.
Expand Down
17 changes: 0 additions & 17 deletions agent.Dockerfile

This file was deleted.

21 changes: 21 additions & 0 deletions integration-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Loading