From a09c70f7dc82220340b5c3af2b0e0b377b56d731 Mon Sep 17 00:00:00 2001 From: Ali Behjati Date: Thu, 9 Jan 2025 13:45:31 +0100 Subject: [PATCH] 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"]