From 3719c13a477c40bbe0c407c8743cc73c9760c8e0 Mon Sep 17 00:00:00 2001 From: Siddharth2207 Date: Thu, 9 Apr 2026 16:01:36 +0530 Subject: [PATCH] lazer pusher --- .../workflows/pyth-lazer-pusher-docker.yml | 45 +++++++++++++++++++ .../bulk-trade-pusher/Dockerfile | 14 +++++- .../bulk-trade-pusher/docker-entrypoint.sh | 29 ++++++++++++ .../bulk-trade-pusher/src/config.rs | 13 ++++-- 4 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/pyth-lazer-pusher-docker.yml create mode 100644 apps/pyth-lazer-pusher/bulk-trade-pusher/docker-entrypoint.sh diff --git a/.github/workflows/pyth-lazer-pusher-docker.yml b/.github/workflows/pyth-lazer-pusher-docker.yml new file mode 100644 index 0000000000..9da74c70f8 --- /dev/null +++ b/.github/workflows/pyth-lazer-pusher-docker.yml @@ -0,0 +1,45 @@ +name: Pyth Lazer Pusher Docker image CI + +on: + push: + workflow_dispatch: + inputs: + tag: + description: 'Tag to give the build. Try to make it unique.' + required: true + +env: + CHANNEL: ${{ inputs.tag || github.head_ref || github.ref_name }} + DOCKER_BUILDKIT: 1 + COMPOSE_DOCKER_CLI_BUILD: 1 + TAG_BASE: rainprotocol/bulk-trade-pusher + +jobs: + build: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: write + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + + - uses: docker/setup-buildx-action@v2 + - uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build bulk-trade-pusher image + run: | + docker build \ + -f apps/pyth-lazer-pusher/bulk-trade-pusher/Dockerfile \ + -t "$TAG_BASE:$CHANNEL" \ + --build-arg GIT_SHA=${{ github.sha }} \ + --build-arg DOCKER_CHANNEL=$CHANNEL \ + . + + - name: Push image + run: docker push "$TAG_BASE:$CHANNEL" diff --git a/apps/pyth-lazer-pusher/bulk-trade-pusher/Dockerfile b/apps/pyth-lazer-pusher/bulk-trade-pusher/Dockerfile index 01087bbde8..2584518757 100644 --- a/apps/pyth-lazer-pusher/bulk-trade-pusher/Dockerfile +++ b/apps/pyth-lazer-pusher/bulk-trade-pusher/Dockerfile @@ -16,12 +16,22 @@ RUN --mount=type=cache,target=/root/.cargo/registry \ # Runtime FROM debian:bookworm-slim + +# set git sha and docker tag from build-time args to run-time env in container +ARG GIT_SHA +ARG DOCKER_CHANNEL +ENV GIT_COMMIT=$GIT_SHA +ENV DOCKER_TAG=$DOCKER_CHANNEL + RUN apt-get update && \ - apt-get install -y --no-install-recommends ca-certificates && \ + apt-get install -y --no-install-recommends ca-certificates bash && \ rm -rf /var/lib/apt/lists/* && \ useradd -r -u 1000 appuser COPY --from=build /src/target/release/bulk-pusher /usr/local/bin/bulk-pusher +COPY apps/pyth-lazer-pusher/bulk-trade-pusher/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh +COPY apps/pyth-lazer-pusher/bulk-trade-pusher/config.toml /etc/bulk-pusher/config.toml +RUN chmod +x /usr/local/bin/docker-entrypoint.sh USER appuser -ENTRYPOINT ["/usr/local/bin/bulk-pusher"] +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] diff --git a/apps/pyth-lazer-pusher/bulk-trade-pusher/docker-entrypoint.sh b/apps/pyth-lazer-pusher/bulk-trade-pusher/docker-entrypoint.sh new file mode 100644 index 0000000000..ef984880e4 --- /dev/null +++ b/apps/pyth-lazer-pusher/bulk-trade-pusher/docker-entrypoint.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# Docker entrypoint for bulk-trade-pusher. +# Converts the SIGNING_KEY_BASE58 env var into a temp key file so the binary +# can run without any mounted files (DigitalOcean / cloud deployment). +# +# Required env vars (set these in DigitalOcean App Platform): +# +# SIGNING_KEY_BASE58 Ed25519 private key (base58) +# BULK_PUSHER__LAZER__ACCESS_TOKEN Pyth Lazer access token +# BULK_PUSHER__LAZER__ENDPOINTS JSON array, e.g. '["wss://pyth-lazer-0.dourolabs.app/v1/stream"]' +# BULK_PUSHER__BULK__ENDPOINTS JSON array, e.g. '["wss://exchange-wss.bulk.trade/ws"]' +# BULK_PUSHER__BULK__ORACLE_ACCOUNT_PUBKEY_BASE58 Oracle account public key (base58) +# BULK_PUSHER__FEEDS__SUBSCRIPTIONS JSON array, e.g. '[{"feed_id":86,"channel":"fixed_rate_1000ms"}]' +# +# Optional env vars (have defaults): +# BULK_PUSHER__FEEDS__UPDATE_INTERVAL default: 100ms +# BULK_PUSHER__PROMETHEUS_ADDRESS default: 0.0.0.0:9090 +# BULK_PUSHER__LAZER__NUM_CONNECTIONS default: 2 +# BULK_PUSHER__LAZER__TIMEOUT default: 5s + +set -e + +if [ -n "${SIGNING_KEY_BASE58}" ]; then + echo "${SIGNING_KEY_BASE58}" > /tmp/signing.key + chmod 600 /tmp/signing.key + export BULK_PUSHER__BULK__SIGNING_KEY_PATH=/tmp/signing.key +fi + +exec /usr/local/bin/bulk-pusher --config /etc/bulk-pusher/config.toml "$@" diff --git a/apps/pyth-lazer-pusher/bulk-trade-pusher/src/config.rs b/apps/pyth-lazer-pusher/bulk-trade-pusher/src/config.rs index 5f3ef621ac..6ad74120c0 100644 --- a/apps/pyth-lazer-pusher/bulk-trade-pusher/src/config.rs +++ b/apps/pyth-lazer-pusher/bulk-trade-pusher/src/config.rs @@ -47,10 +47,15 @@ pub struct BulkConfig { pub fn load_config>(path: P) -> anyhow::Result { let path = path.as_ref(); let config: Config = config::Config::builder() - .add_source(File::with_name( - path.to_str().context("invalid config path")?, - )) - .add_source(Environment::with_prefix("BULK_PUSHER").separator("__")) + .add_source( + File::with_name(path.to_str().context("invalid config path")?) + .required(false), + ) + .add_source( + Environment::with_prefix("BULK_PUSHER") + .separator("__") + .try_parsing(true), + ) .build()? .try_deserialize()?;