Skip to content

Commit 216edd9

Browse files
committed
chore: shrink niluv_node docker image
1 parent bf05259 commit 216edd9

2 files changed

Lines changed: 44 additions & 18 deletions

File tree

.github/workflows/docker.yml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: docker-build-push
33
on:
44
push:
55
tags: [ "v*.*.*" ]
6+
# TODO
7+
pull_request:
68
workflow_dispatch:
79
env:
810
REGISTRY: ghcr.io
@@ -11,25 +13,25 @@ env:
1113
jobs:
1214
build-and-push:
1315
name: Build and Push Docker Images
14-
runs-on: ubuntu-latest
16+
runs-on: ${{ matrix.runner }}
1517
permissions:
1618
contents: read
1719
packages: write
18-
1920
strategy:
21+
fail-fast: false
2022
matrix:
21-
target:
22-
- niluv_node
23+
include:
24+
- arch: amd64
25+
platform: linux/amd64
26+
runner: ubuntu-latest
27+
- arch: arm64
28+
platform: linux/arm64
29+
runner: ubuntu-24.04-arm
2330
steps:
2431
- name: Checkout
2532
uses: actions/checkout@v4
2633
with:
27-
submodules: recursive
28-
29-
- name: Set up QEMU
30-
uses: docker/setup-qemu-action@v3
31-
with:
32-
platforms: linux/arm64
34+
fetch-depth: 0
3335

3436
- name: Set up Docker Buildx
3537
uses: docker/setup-buildx-action@v3
@@ -45,24 +47,25 @@ jobs:
4547
id: meta
4648
uses: docker/metadata-action@v5
4749
with:
48-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.target }}
50+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/niluv_node
4951
tags: |
5052
type=semver,pattern={{version}}
5153
type=semver,pattern={{major}}.{{minor}}
5254
type=semver,pattern={{major}}
5355
type=sha,prefix=sha-
5456
type=raw,value=latest,enable={{is_default_branch}}
5557
56-
- name: Build and push Docker image (${{ matrix.target }})
58+
- name: Build and push Docker image
5759
id: build
5860
uses: docker/build-push-action@v5
5961
with:
6062
context: .
61-
file: ./docker/Dockerfile
62-
target: ${{ matrix.target }}
63-
push: true
63+
file: ./docker/niluv_node.dockerfile
64+
# TODO
65+
# push: true
66+
push: false
6467
tags: ${{ steps.meta.outputs.tags }}
6568
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
69+
cache-from: type=gha
70+
cache-to: type=gha,mode=max
71+
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)