Skip to content

Commit

Permalink
Merge pull request #724 from Levana-Protocol/perp-3443/docker-image-g…
Browse files Browse the repository at this point in the history
…eneration-for-perps-deploy

PERP-3443 | Add github action to generate docker image
  • Loading branch information
lvn-talented-dragon authored Jun 13, 2024
2 parents 7672c86 + 5a51cca commit 658b791
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .ci/perps-deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
50 changes: 50 additions & 0 deletions .github/workflows/perps-deploy.yaml
Original file line number Diff line number Diff line change
@@ -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: [email protected]
- 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' }}
14 changes: 14 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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-deploy binary in release mode
cargo-perps-deploy-release:
cargo build --bin perps-deploy --release --target x86_64-unknown-linux-musl

# 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-deploy docker image
push-perps-deploy-image:
docker push ghcr.io/levana-protocol/levana-perps/perps-deploy:{{GIT_SHA}}

0 comments on commit 658b791

Please sign in to comment.