Skip to content

Commit

Permalink
Add workflow and Dockerfile necessary to build the rust services
Browse files Browse the repository at this point in the history
  • Loading branch information
m30m committed Feb 5, 2024
1 parent fe7e0c6 commit bd03e98
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 86 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/push-rust-services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and Push Rust Services Image
on:
push:
tags:
- server-v*
workflow_dispatch:
inputs:
dispatch_description:
description: "Dispatch description"
required: true
type: string
permissions:
contents: read
id-token: write
jobs:
server-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set image tag to version of the git tag
if: ${{ startsWith(github.ref, 'refs/tags/server-v') }}
run: |
PREFIX="refs/tags/server-"
VERSION="${GITHUB_REF:${#PREFIX}}"
echo "IMAGE_TAG=${VERSION}" >> "${GITHUB_ENV}"
- name: Set image tag to the git commit hash
if: ${{ !startsWith(github.ref, 'refs/tags/server-v') }}
run: |
echo "IMAGE_TAG=${{ github.sha }}" >> "${GITHUB_ENV}"
- uses: aws-actions/configure-aws-credentials@8a84b07f2009032ade05a88a28750d733cc30db1
with:
role-to-assume: arn:aws:iam::192824654885:role/github-actions-ecr
aws-region: eu-west-2
- uses: aws-actions/amazon-ecr-login@v1
id: ecr_login
- run: |
DOCKER_BUILDKIT=1 docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
env:
ECR_REGISTRY: ${{ steps.ecr_login.outputs.registry }}
ECR_REPOSITORY: ${{ github.event.repository.name }}
44 changes: 44 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
ARG RUST_VERSION=1.66.1

# Get the solidity dependencies using npm
FROM node:21-alpine3.18 AS npm_build
WORKDIR /src
COPY per_multicall per_multicall
WORKDIR /src/per_multicall
RUN npm install


FROM rust:${RUST_VERSION} AS build
# Set default toolchain
RUN rustup default nightly-2023-07-23

# Install dependencies
RUN curl -L https://foundry.paradigm.xyz | bash
ENV PATH="${PATH}:/root/.foundry/bin/"
RUN foundryup

# Add solidity dependencies
WORKDIR /src
COPY per_multicall per_multicall
COPY --from=npm_build /src/per_multicall/node_modules/ /src/per_multicall/node_modules/
WORKDIR /src/per_multicall
RUN forge install foundry-rs/forge-std --no-git --no-commit
RUN forge install OpenZeppelin/openzeppelin-contracts --no-git --no-commit

# Build auction-server
WORKDIR /src
COPY auction-server auction-server
WORKDIR /src/auction-server
RUN --mount=type=cache,target=/root/.cargo/registry cargo build --release

# Build vault-simulator
WORKDIR /src
COPY vault-simulator vault-simulator
WORKDIR /src/vault-simulator
RUN --mount=type=cache,target=/root/.cargo/registry cargo build --release


FROM rust:${RUST_VERSION}
# Copy artifacts from other images
COPY --from=build /src/auction-server/target/release/auction-server /usr/local/bin/
COPY --from=build /src/vault-simulator/target/release/vault-simulator /usr/local/bin/
101 changes: 17 additions & 84 deletions auction-server/Cargo.lock

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

1 change: 0 additions & 1 deletion auction-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ utoipa-swagger-ui = { version = "3.1.4", features = ["axum"] }
serde_yaml = "0.9.25"
ethers = "2.0.10"
axum-macros = "0.4.0"
axum-auth = "0.7.0"
2 changes: 1 addition & 1 deletion per_multicall/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Run the following commands to install necessary libraries:

```shell
$ npm install @pythnetwork/pyth-sdk-solidity
$ npm install
$ forge install foundry-rs/forge-std --no-git --no-commit
$ forge install OpenZeppelin/openzeppelin-contracts --no-git --no-commit
```
Expand Down

0 comments on commit bd03e98

Please sign in to comment.