diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3c7c5de..ec7044d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -11,26 +11,31 @@ env: jobs: build-and-push: name: Build and Push Docker Images - runs-on: ubuntu-latest + runs-on: ${{ matrix.runner }} permissions: contents: read packages: write - strategy: + fail-fast: false matrix: target: - blacklight_node - keeper + arch: + - amd64 + - arm64 + include: + - arch: amd64 + platform: linux/amd64 + runner: ubuntu-latest + - arch: arm64 + platform: linux/arm64 + runner: ubuntu-24.04-arm steps: - name: Checkout uses: actions/checkout@v4 with: - submodules: recursive - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: linux/arm64 + fetch-depth: 0 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -63,18 +68,18 @@ jobs: type=sha,prefix=sha- type=raw,value=latest,enable={{is_default_branch}} - - name: Build and push Docker image (${{ matrix.target }}) + - name: Build and push docker image id: build - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: . - file: ./docker/Dockerfile - target: ${{ matrix.target }} + file: ./docker/${{ matrix.target }}.dockerfile push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha,scope=${{ matrix.target }} cache-to: type=gha,mode=max,scope=${{ matrix.target }} - platforms: linux/amd64,linux/arm64 + platforms: ${{ matrix.platform }} build-args: | BLACKLIGHT_VERSION=${{ steps.version.outputs.version }} + provenance: false diff --git a/docker/blacklight_node.dockerfile b/docker/blacklight_node.dockerfile new file mode 100644 index 0000000..7af744f --- /dev/null +++ b/docker/blacklight_node.dockerfile @@ -0,0 +1,27 @@ +FROM rust:1.91-alpine AS builder + +ARG BLACKLIGHT_VERSION + +WORKDIR /app + +RUN apk add --no-cache musl-dev git pkgconf openssl-dev + +# Copy project files +COPY Cargo.toml ./ +COPY crates ./crates +COPY nilcc-simulator ./nilcc-simulator +COPY keeper ./keeper +COPY blacklight-node ./blacklight-node +COPY monitor ./monitor + +RUN BLACKLIGHT_VERSION="${BLACKLIGHT_VERSION}" RUSTFLAGS="-Ctarget-feature=-crt-static" cargo build --release --bin blacklight-node && \ + mkdir -p /out/bin && \ + mv target/release/blacklight-node /out/bin/ + +FROM alpine + +RUN apk add libgcc openssl +WORKDIR /app + +COPY --from=builder /out/bin/blacklight-node /usr/local/bin/blacklight-node +ENTRYPOINT ["/usr/local/bin/blacklight-node"] diff --git a/docker/keeper.dockerfile b/docker/keeper.dockerfile new file mode 100644 index 0000000..618b811 --- /dev/null +++ b/docker/keeper.dockerfile @@ -0,0 +1,26 @@ +FROM rust:1.91-alpine AS builder + +WORKDIR /app + +RUN apk add --no-cache musl-dev git pkgconf openssl-dev + +# Copy project files +COPY Cargo.toml ./ +COPY crates ./crates +COPY nilcc-simulator ./nilcc-simulator +COPY keeper ./keeper +COPY blacklight-node ./blacklight-node +COPY monitor ./monitor + +RUN RUSTFLAGS="-Ctarget-feature=-crt-static" cargo build --release --bin keeper && \ + mkdir -p /out/bin && \ + mv target/release/keeper /out/bin/ + +FROM alpine + +RUN apk add libgcc openssl +WORKDIR /app + +COPY --from=builder /out/bin/keeper /usr/local/bin/keeper +ENTRYPOINT ["/usr/local/bin/keeper"] +