Skip to content

Commit 9389fdc

Browse files
committed
ci: add simple public docker image build
1 parent cd5db4d commit 9389fdc

3 files changed

Lines changed: 142 additions & 0 deletions

File tree

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Docker Image Build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
build-binary:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
binary-artifact: ${{ steps.upload.outputs.artifact-id }}
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v5
19+
20+
- name: Install system dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -y protobuf-compiler
24+
25+
- name: Setup Rust
26+
uses: dtolnay/rust-toolchain@stable
27+
with:
28+
toolchain: stable
29+
30+
- name: Cache Rust dependencies
31+
uses: actions/cache@v3
32+
with:
33+
path: |
34+
~/.cargo/registry
35+
~/.cargo/git
36+
target
37+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
38+
39+
- name: Build midnight-node binary
40+
run: |
41+
cargo build --release --package midnight-node
42+
43+
- name: Upload binary artifact
44+
id: upload
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: midnight-node-binary
48+
path: target/release/midnight-node
49+
retention-days: 1
50+
51+
build-image:
52+
needs: build-binary
53+
runs-on: ubuntu-latest
54+
permissions:
55+
contents: read
56+
packages: write
57+
58+
steps:
59+
- name: Checkout repository
60+
uses: actions/checkout@v5
61+
62+
- name: Download binary artifact
63+
uses: actions/download-artifact@v4
64+
with:
65+
name: midnight-node-binary
66+
path: .
67+
68+
- name: Make binary executable
69+
run: chmod +x midnight-node
70+
71+
- name: Log into registry ${{ env.REGISTRY }}
72+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
73+
with:
74+
registry: ${{ env.REGISTRY }}
75+
username: ${{ github.actor }}
76+
password: ${{ secrets.GITHUB_TOKEN }}
77+
78+
- name: Extract Docker metadata
79+
id: meta
80+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
81+
with:
82+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
83+
84+
- name: Build and push Docker image
85+
uses: docker/build-push-action@v5
86+
with:
87+
context: .
88+
file: ./Dockerfile
89+
push: true
90+
tags: ${{ steps.meta.outputs.tags }}
91+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM debian:trixie-slim
2+
3+
ENV BASE_PATH=/node/chain
4+
ENV RUST_BACKTRACE=1
5+
6+
# ntp to keep correct time
7+
# curl to enable compose healthchecks
8+
RUN apt-get update -qq && \
9+
apt-get upgrade -y -qq && \
10+
apt-get install -y -qq --no-install-recommends ca-certificates curl procps strace \
11+
gdb vim jq tree build-essential git cmake wget libtool autoconf automake && \
12+
# Build libfaketime with FORCE_MONOTONIC_FIX and FORCE_PTHREAD_NONVER
13+
git clone https://github.com/wolfcw/libfaketime.git && \
14+
cd /libfaketime/src && \
15+
make clean && \
16+
CFLAGS="-DFORCE_MONOTONIC_FIX -DFORCE_PTHREAD_NONVER" make && \
17+
make install && \
18+
cd / && rm -rf /libfaketime && \
19+
# Download bytehound
20+
wget -q https://github.com/koute/bytehound/releases/download/0.11.0/bytehound-x86_64-unknown-linux-gnu.tgz && \
21+
[ -f bytehound-x86_64-unknown-linux-gnu.tgz ] && \
22+
tar -xzvf bytehound-x86_64-unknown-linux-gnu.tgz && \
23+
mv libbytehound.so /usr/lib/libbytehound.so && \
24+
rm -rf bytehound* && \
25+
# Cleanup
26+
apt-get clean && rm -rf /var/lib/apt/lists/*
27+
28+
COPY .envrc ./bin/.envrc
29+
COPY res/ ./res/
30+
COPY node/bin/entrypoint.sh /entrypoint.sh
31+
COPY midnight-node /midnight-node
32+
33+
RUN useradd -u 10001 -d /nonexistent -s /usr/sbin/nologin -M -U -c "" appuser && passwd -l appuser && \
34+
chmod +x /midnight-node && \
35+
chown appuser:appuser /midnight-node
36+
# Note: Don't switch to appuser here - entrypoint.sh will do it with runuser
37+
38+
EXPOSE 30333 9933 9944 9615
39+
ENTRYPOINT ["/entrypoint.sh"]

res/cfg/testnet-02.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
chain = "res/testnet-02/chain-spec-raw.json"
2+
base_path = "node/chain"
3+
4+
chainspec_name = "testnet-02-1"
5+
chainspec_id = "testnet-02"
6+
chainspec_network_id = "testnet"
7+
chainspec_genesis_state = "res/genesis/genesis_state_testnet-02.mn"
8+
chainspec_genesis_block = "res/genesis/genesis_block_testnet-02.mn"
9+
chainspec_chain_type = "live"
10+
chainspec_pc_chain_config = "res/testnet-02/pc-chain-config.json"
11+
chainspec_cngd_config = "res/devnet/cngd-config.json"
12+
chainspec_federated_authority_config = "res/testnet-02/federated-authority-config.json"

0 commit comments

Comments
 (0)