Skip to content

Commit 8e83191

Browse files
committed
chore: shrink niluv_node docker image
1 parent bf05259 commit 8e83191

2 files changed

Lines changed: 39 additions & 17 deletions

File tree

.github/workflows/docker.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ 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:
21-
target:
22-
- niluv_node
21+
include:
22+
- arch: amd64
23+
platform: linux/amd64
24+
runner: ubuntu-latest
25+
- arch: arm64
26+
platform: linux/arm64
27+
runner: ubuntu-24.04-arm
2328
steps:
2429
- name: Checkout
2530
uses: actions/checkout@v4
2631
with:
27-
submodules: recursive
28-
29-
- name: Set up QEMU
30-
uses: docker/setup-qemu-action@v3
31-
with:
32-
platforms: linux/arm64
32+
fetch-depth: 0
3333

3434
- name: Set up Docker Buildx
3535
uses: docker/setup-buildx-action@v3
@@ -45,24 +45,23 @@ jobs:
4545
id: meta
4646
uses: docker/metadata-action@v5
4747
with:
48-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.target }}
48+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/niluv_node
4949
tags: |
5050
type=semver,pattern={{version}}
5151
type=semver,pattern={{major}}.{{minor}}
5252
type=semver,pattern={{major}}
5353
type=sha,prefix=sha-
5454
type=raw,value=latest,enable={{is_default_branch}}
5555
56-
- name: Build and push Docker image (${{ matrix.target }})
56+
- name: Build and push Docker image
5757
id: build
5858
uses: docker/build-push-action@v5
5959
with:
6060
context: .
61-
file: ./docker/Dockerfile
62-
target: ${{ matrix.target }}
61+
file: ./docker/niluv_node.dockerfile
6362
push: true
6463
tags: ${{ steps.meta.outputs.tags }}
6564
labels: ${{ steps.meta.outputs.labels }}
66-
cache-from: type=gha,scope=${{ matrix.target }}
67-
cache-to: type=gha,mode=max,scope=${{ matrix.target }}
68-
platforms: linux/amd64,linux/arm64
65+
cache-from: type=gha
66+
cache-to: type=gha,mode=max
67+
provenance: false

docker/niluv_node.dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 Cargo.toml ./
8+
COPY src ./src
9+
COPY config ./config
10+
COPY data ./data
11+
12+
RUN RUSTFLAGS="-Ctarget-feature=-crt-static" cargo build --release --bin niluv_node && \
13+
mkdir -p /out/bin && \
14+
mv target/release/niluv_node /out/bin/
15+
16+
FROM alpine
17+
18+
RUN apk add libgcc openssl
19+
USER appuser
20+
WORKDIR /app
21+
22+
COPY --from=builder /out/bin/niluv_node /usr/local/bin/niluv_node
23+
ENTRYPOINT ["/usr/local/bin/niluv_node"]

0 commit comments

Comments
 (0)