Skip to content

Commit 933f18d

Browse files
committed
Custom solana-validator dockerfile, ci flow for building docker images
1 parent 5e13d77 commit 933f18d

File tree

5 files changed

+146
-0
lines changed

5 files changed

+146
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
set -x
3+
4+
echo "$CHANGED_FILES"
5+
6+
CHANGED_DIRS=$(
7+
for FILE in ${CHANGED_FILES}
8+
do
9+
# Finds directories with "Dockerfile" files in them
10+
# in directories that have changed
11+
DIR=$(dirname "$FILE")
12+
if [ "$DIR" != "." ]
13+
then
14+
find "$DIR" -type d -exec test -e '{}'/Dockerfile \; -print | sed -e 's/^images\///'
15+
fi
16+
done | uniq | jq -c --slurp --raw-input 'split("\n")[:-1] | unique | { "image": . }'
17+
)
18+
19+
echo "dirs=${CHANGED_DIRS}" >> "$GITHUB_OUTPUT"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -x
3+
4+
export CHANGED_FILES="README.md
5+
images/solana-validator/Dockerfile
6+
havoc/chaos_listener.go
7+
havoc/.gitignore
8+
havoc/utils.go"
9+
10+
export GITHUB_OUTPUT="/dev/stdout"
11+
12+
./.github/ci-scripts/create-image-matrix.sh
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: pull-request
2+
on: pull_request
3+
4+
jobs:
5+
# hadolint:
6+
# name: Lint Dockerfiles
7+
# runs-on: ubuntu-latest
8+
# steps:
9+
# - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
10+
# - uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf #v3.1.0
11+
# with:
12+
# recursive: true
13+
14+
chkmodified:
15+
name: Check modified
16+
runs-on: ubuntu-latest
17+
outputs:
18+
dockerfile_dirs: ${{ steps.list_dockerfile_dirs.outputs.dirs }}
19+
steps:
20+
- name: Checkout the repo
21+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
22+
23+
- name: Get changed files
24+
id: get_changed_files
25+
uses: tj-actions/changed-files@0874344d6ebbaa00a27da73276ae7162fadcaf69 # v44.3.0
26+
with:
27+
fetch_depth: 1000
28+
29+
- name: List changed directories with Docker files
30+
id: list_dockerfile_dirs
31+
run: .github/ci-scripts/create-image-matrix.sh
32+
env:
33+
CHANGED_FILES: ${{ steps.get_changed_files.outputs.all_modified_files }}
34+
ECR_REPO_TYPE: public
35+
36+
build-public:
37+
needs: chkmodified
38+
runs-on: ubuntu-latest
39+
environment: ecr-prod-publish
40+
permissions:
41+
id-token: write
42+
contents: read
43+
strategy:
44+
matrix: ${{ fromJson(needs.chkmodified.outputs.dockerfile_dirs) }}
45+
fail-fast: false
46+
47+
steps:
48+
- name: Build
49+
uses: smartcontractkit/.github/actions/cicd-build-publish-docker@crib-626/multiplatform # v0.1.0
50+
with:
51+
# general inputs
52+
ecr-repo-name: ${{ matrix.image }}
53+
publish: 'false'
54+
dockerfile: ./images/${{ matrix.image }}/Dockerfile
55+
context: ./images/${{ matrix.image }}/
56+
registry-type: 'public'
57+
registry-alias: 'w0i8p0z9'
58+
multi-platform: 'true'
59+
platforms: linux/amd64,linux/arm64
60+
tags: |
61+
type=sha,prefix=pr=,event=pr
62+
# aws inputs
63+
aws-role-arn: ${{ secrets.AWS_OIDC_PUBLISH_ECR_ROLE_ARN }}
64+
aws-account-number: ${{ secrets.AWS_PROD_ACCOUNT_NUMBER }}

images/solana-validator/Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Base image
2+
FROM debian:bookworm AS base
3+
4+
ARG AGAVE_VERSION=2.0.24
5+
ARG RUST_VERSION=stable
6+
7+
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
8+
9+
WORKDIR /app
10+
11+
RUN mkdir -p "/app/bin"
12+
13+
ENV PATH="/app/bin:${PATH}"
14+
15+
# Builder image
16+
FROM base AS builder
17+
18+
RUN apt update && \
19+
apt-get install -y \
20+
build-essential \
21+
pkg-config \
22+
protobuf-compiler \
23+
clang cmake curl libudev-dev && \
24+
rm -rf /var/lib/apt/lists/*
25+
26+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain $RUST_VERSION -y
27+
ENV PATH="/root/.cargo/bin:${PATH}"
28+
29+
RUN curl https://codeload.github.com/anza-xyz/agave/tar.gz/refs/tags/v$AGAVE_VERSION | tar xvz
30+
RUN mv /app/agave-$AGAVE_VERSION /app/agave
31+
32+
WORKDIR /app/agave
33+
RUN cargo build --bin solana-test-validator --release
34+
RUN cp target/release/solana-test-validator /app/bin/
35+
36+
# Final app image
37+
FROM base AS final
38+
39+
RUN apt update && \
40+
apt-get install -y bzip2 && \
41+
rm -rf /var/lib/apt/lists/*
42+
43+
COPY --from=builder /app/bin/* /app/bin

images/solana-validator/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Solana validator
2+
3+
Customized Solana validator image for testing, built from agave sources.
4+
5+
## Why
6+
7+
Agave doesn't provide arm64 images, this customized dockerfile supports both amd64 and arm64.
8+
Arm64 is required to test locally on MacBook Apple chips, as well as in AWS graviton instances.

0 commit comments

Comments
 (0)