From d2da9b7f1c6bdd928262945e38de6b88268eb1e0 Mon Sep 17 00:00:00 2001 From: Levana Talented Dragon Date: Thu, 13 Jun 2024 15:39:12 +0200 Subject: [PATCH 1/2] PERP-3443 feat: add github action to generate docker image --- .ci/perps-deploy/Dockerfile | 16 +++++++++ .github/workflows/perps-deploy.yaml | 50 +++++++++++++++++++++++++++++ justfile | 14 ++++++++ 3 files changed, 80 insertions(+) create mode 100644 .ci/perps-deploy/Dockerfile create mode 100644 .github/workflows/perps-deploy.yaml diff --git a/.ci/perps-deploy/Dockerfile b/.ci/perps-deploy/Dockerfile new file mode 100644 index 000000000..5643b0a09 --- /dev/null +++ b/.ci/perps-deploy/Dockerfile @@ -0,0 +1,16 @@ +FROM alpine:3.19.1 + +ADD --chmod=755 https://github.com/fpco/health-check/releases/download/v0.1.0/health-check-x86_64-unknown-linux-musl /usr/bin/health-check + +RUN mkdir -p /app/packages/perps-exes/assets + +USER 1000 + +WORKDIR /app + +COPY --chmod=755 --chown=1000 ./mainnet-factories.toml /app/packages/perps-exes/assets +COPY --chmod=755 --chown=1000 perps-deploy /usr/bin/perps-deploy + +ENTRYPOINT [ "/usr/bin/health-check", "--task-output-timeout", "90000", "--app-description", "Perps Deploy (K8s mainnet)", "perps-deploy" ] + +CMD [ "serve" ] diff --git a/.github/workflows/perps-deploy.yaml b/.github/workflows/perps-deploy.yaml new file mode 100644 index 000000000..db3f4c65f --- /dev/null +++ b/.github/workflows/perps-deploy.yaml @@ -0,0 +1,50 @@ +name: Perps Deploy Docker Image + +on: + workflow_dispatch: + schedule: + # For cache, run at 9 AM UTC daily + - cron: "0 9 * * *" + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 + CARGO_NET_RETRY: 10 + RUST_BACKTRACE: short + RUSTUP_MAX_RETRIES: 10 + +jobs: + perps-deploy-image: + runs-on: ubuntu-latest + concurrency: + group: ci-perps-deploy-${{ github.ref }} + cancel-in-progress: true + steps: + - uses: actions/checkout@v4 + - uses: taiki-e/install-action@v2 + with: + tool: just@1.25.2 + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: dtolnay/rust-toolchain@master + with: + toolchain: 1.75.0 + components: rustfmt, clippy + targets: x86_64-unknown-linux-musl + - uses: Swatinem/rust-cache@v2 + with: + workspaces: | + . + - name: Dependencies + run: sudo apt install musl-tools -y + - name: Build perps-deploy binary + run: just cargo-perps-deploy-release + - name: Build image + run: just build-perps-deploy-image + - name: Push image + run: just push-perps-deploy-image + if: ${{ github.event_name != 'schedule' }} diff --git a/justfile b/justfile index 011f0fe68..b8962a3bf 100644 --- a/justfile +++ b/justfile @@ -282,3 +282,17 @@ build-market-params-image: # Push perps-market-params docker image push-market-params-image: docker push ghcr.io/levana-protocol/levana-perps/perps-market-params:{{GIT_SHA}} + +# Build perps-market-params binary in release mode +cargo-perps-deploy-release: + cargo build --bin perps-deploy --release --target x86_64-unknown-linux-musl + +# Build perps-market-params docker image +build-perps-deploy-image: + cp ./packages/perps-exes/assets/mainnet-factories.toml .ci/perps-deploy/ + cp target/x86_64-unknown-linux-musl/release/perps-deploy .ci/perps-deploy/ + cd .ci/perps-deploy && docker image build . -f Dockerfile -t ghcr.io/levana-protocol/levana-perps/perps-deploy:{{GIT_SHA}} + +# Push perps-market-params docker image +push-perps-deploy-image: + docker push ghcr.io/levana-protocol/levana-perps/perps-deploy:{{GIT_SHA}} From 5a51cca59cdb2d02df55cfb9e6b0a2d17c71e914 Mon Sep 17 00:00:00 2001 From: Levana Talented Dragon Date: Thu, 13 Jun 2024 15:43:52 +0200 Subject: [PATCH 2/2] PERP-3443 feat: update comment on justfile --- justfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/justfile b/justfile index b8962a3bf..dcb369566 100644 --- a/justfile +++ b/justfile @@ -283,16 +283,16 @@ build-market-params-image: push-market-params-image: docker push ghcr.io/levana-protocol/levana-perps/perps-market-params:{{GIT_SHA}} -# Build perps-market-params binary in release mode +# Build perps-deploy binary in release mode cargo-perps-deploy-release: cargo build --bin perps-deploy --release --target x86_64-unknown-linux-musl -# Build perps-market-params docker image +# Build perps-deploy docker image build-perps-deploy-image: cp ./packages/perps-exes/assets/mainnet-factories.toml .ci/perps-deploy/ cp target/x86_64-unknown-linux-musl/release/perps-deploy .ci/perps-deploy/ cd .ci/perps-deploy && docker image build . -f Dockerfile -t ghcr.io/levana-protocol/levana-perps/perps-deploy:{{GIT_SHA}} -# Push perps-market-params docker image +# Push perps-deploy docker image push-perps-deploy-image: docker push ghcr.io/levana-protocol/levana-perps/perps-deploy:{{GIT_SHA}}