Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build/push Docker images in CI #259

Merged
merged 4 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: docker

on:
push:
branches:
- main
tags:
- v*

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
IMAGE_NAME: ${{ github.repository_owner}}/mev-rs

jobs:
extract-version:
runs-on: ubuntu-22.04
steps:
- name: Extract version (if main)
if: github.event.ref == 'refs/heads/main'
run: |
echo "VERSION=latest" >> $GITHUB_ENV
- name: Extract version (if tagged release)
if: startsWith(github.event.ref, 'refs/tags')
run: |
echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV
outputs:
VERSION: ${{ env.VERSION }}
build-docker:
name: build-docker-${{ matrix.binary }}
runs-on: ubuntu-22.04
strategy:
matrix:
binary: [x86_64]
include:
- profile: maxperf

needs: [extract-version]
env:
VERSION: ${{ needs.extract-version.outputs.VERSION }}
steps:
- uses: actions/checkout@v4
- name: Dockerhub login
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
file: ./Dockerfile
context: .
platforms: linux/x86_64
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.VERSION }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:

- name: Build mev-rs
run: |
cargo install --path bin/mev --locked
cargo install --profile maxperf --path bin/mev --locked
mkdir artifacts
mv ~/.cargo/bin/mev ./artifacts
cd artifacts
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json

ARG BUILD_PROFILE=release
ARG BUILD_PROFILE=maxperf
ENV BUILD_PROFILE ${BUILD_PROFILE}
ARG FEATURES=""
ENV FEATURES ${FEATURES}
Expand Down
2 changes: 1 addition & 1 deletion bin/mev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ clap = { workspace = true, features = ["derive", "env"] }
eyre = { workspace = true }

ethereum-consensus = { workspace = true }
reth = { workspace = true, optional = true }
reth = { workspace = true, optional = true, features = ["jemalloc"] }
1 change: 1 addition & 0 deletions nix/mev-rs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ let
pname = "mev-rs";
src = crane.cleanCargoSource (crane.path ../.);
CARGO_PROFILE = "maxperf";
RUSTFLAGS = "-C target-cpu=native";
cargoExtraArgs = "--locked ${feature-set}";
buildInputs = lib.optionals pkgs.stdenv.isLinux [
openssl
Expand Down
Loading