Skip to content

Commit ef864f6

Browse files
committed
chore: shrink niluv_node docker image
1 parent 6c27277 commit ef864f6

3 files changed

Lines changed: 71 additions & 13 deletions

File tree

.github/workflows/docker.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,31 @@ env:
1111
jobs:
1212
build-and-push:
1313
name: Build and Push Docker Images
14-
runs-on: ubuntu-latest
14+
runs-on: ${{ matrix.runner }}
1515
permissions:
1616
contents: read
1717
packages: write
18-
1918
strategy:
19+
fail-fast: false
2020
matrix:
2121
target:
2222
- blacklight_node
2323
- keeper
24+
arch:
25+
- amd64
26+
- arm64
27+
include:
28+
- arch: amd64
29+
platform: linux/amd64
30+
runner: ubuntu-latest
31+
- arch: arm64
32+
platform: linux/arm64
33+
runner: ubuntu-24.04-arm
2434
steps:
2535
- name: Checkout
2636
uses: actions/checkout@v4
2737
with:
28-
submodules: recursive
29-
30-
- name: Set up QEMU
31-
uses: docker/setup-qemu-action@v3
32-
with:
33-
platforms: linux/arm64
38+
fetch-depth: 0
3439

3540
- name: Set up Docker Buildx
3641
uses: docker/setup-buildx-action@v3
@@ -63,18 +68,18 @@ jobs:
6368
type=sha,prefix=sha-
6469
type=raw,value=latest,enable={{is_default_branch}}
6570
66-
- name: Build and push Docker image (${{ matrix.target }})
71+
- name: Build and push docker image
6772
id: build
68-
uses: docker/build-push-action@v5
73+
uses: docker/build-push-action@v6
6974
with:
7075
context: .
71-
file: ./docker/Dockerfile
72-
target: ${{ matrix.target }}
76+
file: ./docker/${{ matrix.target }}.dockerfile
7377
push: true
7478
tags: ${{ steps.meta.outputs.tags }}
7579
labels: ${{ steps.meta.outputs.labels }}
7680
cache-from: type=gha,scope=${{ matrix.target }}
7781
cache-to: type=gha,mode=max,scope=${{ matrix.target }}
78-
platforms: linux/amd64,linux/arm64
82+
platforms: ${{ matrix.platform }}
7983
build-args: |
8084
BLACKLIGHT_VERSION=${{ steps.version.outputs.version }}
85+
provenance: false

docker/blacklight_node.dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM rust:1.91-alpine AS builder
2+
3+
ARG BLACKLIGHT_VERSION
4+
5+
WORKDIR /app
6+
7+
RUN apk add --no-cache musl-dev git pkgconf openssl-dev
8+
9+
# Copy project files
10+
COPY Cargo.toml ./
11+
COPY crates ./crates
12+
COPY nilcc-simulator ./nilcc-simulator
13+
COPY keeper ./keeper
14+
COPY blacklight-node ./blacklight-node
15+
COPY monitor ./monitor
16+
17+
RUN BLACKLIGHT_VERSION="${BLACKLIGHT_VERSION}" RUSTFLAGS="-Ctarget-feature=-crt-static" cargo build --release --bin blacklight-node && \
18+
mkdir -p /out/bin && \
19+
mv target/release/blacklight-node /out/bin/
20+
21+
FROM alpine
22+
23+
RUN apk add libgcc openssl
24+
WORKDIR /app
25+
26+
COPY --from=builder /out/bin/blacklight-node /usr/local/bin/blacklight-node
27+
ENTRYPOINT ["/usr/local/bin/blacklight-node"]

docker/keeper.dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM rust:1.91-alpine AS builder
2+
3+
WORKDIR /app
4+
5+
RUN apk add --no-cache musl-dev git pkgconf openssl-dev
6+
7+
# Copy project files
8+
COPY Cargo.toml ./
9+
COPY crates ./crates
10+
COPY nilcc-simulator ./nilcc-simulator
11+
COPY keeper ./keeper
12+
COPY blacklight-node ./blacklight-node
13+
COPY monitor ./monitor
14+
15+
RUN RUSTFLAGS="-Ctarget-feature=-crt-static" cargo build --release --bin keeper && \
16+
mkdir -p /out/bin && \
17+
mv target/release/keeper /out/bin/
18+
19+
FROM alpine
20+
21+
RUN apk add libgcc openssl
22+
WORKDIR /app
23+
24+
COPY --from=builder /out/bin/keeper /usr/local/bin/keeper
25+
ENTRYPOINT ["/usr/local/bin/keeper"]
26+

0 commit comments

Comments
 (0)