Skip to content

Commit 4b20e51

Browse files
authored
Merge pull request #259 from ralexstokes/docker-ci
Build/push Docker images in CI
2 parents 6612bff + 8d8fa69 commit 4b20e51

File tree

5 files changed

+63
-3
lines changed

5 files changed

+63
-3
lines changed

.github/workflows/docker.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: docker
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- v*
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
env:
15+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
16+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
17+
IMAGE_NAME: ${{ github.repository_owner}}/mev-rs
18+
19+
jobs:
20+
extract-version:
21+
runs-on: ubuntu-22.04
22+
steps:
23+
- name: Extract version (if main)
24+
if: github.event.ref == 'refs/heads/main'
25+
run: |
26+
echo "VERSION=latest" >> $GITHUB_ENV
27+
- name: Extract version (if tagged release)
28+
if: startsWith(github.event.ref, 'refs/tags')
29+
run: |
30+
echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV
31+
outputs:
32+
VERSION: ${{ env.VERSION }}
33+
build-docker:
34+
name: build-docker-${{ matrix.binary }}
35+
runs-on: ubuntu-22.04
36+
strategy:
37+
matrix:
38+
binary: [x86_64]
39+
include:
40+
- profile: maxperf
41+
42+
needs: [extract-version]
43+
env:
44+
VERSION: ${{ needs.extract-version.outputs.VERSION }}
45+
steps:
46+
- uses: actions/checkout@v4
47+
- name: Dockerhub login
48+
run: |
49+
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
50+
- name: Set up Docker Buildx
51+
uses: docker/setup-buildx-action@v3
52+
- name: Build and push
53+
uses: docker/build-push-action@v5
54+
with:
55+
file: ./Dockerfile
56+
context: .
57+
platforms: linux/x86_64
58+
push: true
59+
tags: ${{ env.IMAGE_NAME }}:${{ env.VERSION }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454

5555
- name: Build mev-rs
5656
run: |
57-
cargo install --path bin/mev --locked
57+
cargo install --profile maxperf --path bin/mev --locked
5858
mkdir artifacts
5959
mv ~/.cargo/bin/mev ./artifacts
6060
cd artifacts

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN cargo chef prepare --recipe-path recipe.json
99
FROM chef AS builder
1010
COPY --from=planner /app/recipe.json recipe.json
1111

12-
ARG BUILD_PROFILE=release
12+
ARG BUILD_PROFILE=maxperf
1313
ENV BUILD_PROFILE ${BUILD_PROFILE}
1414
ARG FEATURES=""
1515
ENV FEATURES ${FEATURES}

bin/mev/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ clap = { workspace = true, features = ["derive", "env"] }
3535
eyre = { workspace = true }
3636

3737
ethereum-consensus = { workspace = true }
38-
reth = { workspace = true, optional = true }
38+
reth = { workspace = true, optional = true, features = ["jemalloc"] }

nix/mev-rs.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ let
66
pname = "mev-rs";
77
src = crane.cleanCargoSource (crane.path ../.);
88
CARGO_PROFILE = "maxperf";
9+
RUSTFLAGS = "-C target-cpu=native";
910
cargoExtraArgs = "--locked ${feature-set}";
1011
buildInputs = lib.optionals pkgs.stdenv.isLinux [
1112
openssl

0 commit comments

Comments
 (0)