From 48d68107d9a752c1dfdd1c5c55251fbd7638fcbf Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Tue, 26 Dec 2023 21:09:49 +0100 Subject: [PATCH] Minor Docker enhancements # Description This PR: - Sets some additional RFC standard LABELS to our Docker container - Upload the container to both GitHub and DockerHub registries (PRs do not upload to DH) - Minor Dockerfile efficiencies. It's a follow up from #1656 --- .github/workflows/build-docker.yml | 19 +++++++++++++------ docker/centrifuge-chain/Dockerfile | 19 ++----------------- docker/scripts/check-node-ready | 27 --------------------------- 3 files changed, 15 insertions(+), 50 deletions(-) delete mode 100644 docker/scripts/check-node-ready diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index b3ccb5d521..403f1440dc 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -11,7 +11,8 @@ on: pull_request: paths: - ".github/workflows/build-docker.yml" - - "docker/" + - "docker/centrifuge-chain" + - "docker/scripts" - ".dockerignore" concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}${{ github.event_name }} @@ -33,11 +34,11 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 #v3 - # - name: DockerHub Registry Login - # uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d - # with: - # username: ${{ secrets.DOCKER_HUB_USERNAME }} - # password: ${{ secrets.DOCKER_HUB_TOKEN }} + - name: DockerHub Registry Login + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} - name: Github Registry login uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d @@ -61,6 +62,12 @@ jobs: type=ref,event=tag,suffix=-{{sha}}-${{ env.NOW }},prefix=${{ matrix.target == 'test' && 'test-' || '' }} type=ref,event=pr,suffix=-{{sha}}-${{ env.NOW }},prefix=${{ matrix.target == 'test' && 'test-' || '' }}PR type=ref,event=branch,prefix=${{ matrix.target == 'test' && 'test-' || '' }},suffix=-{{sha}}-${{ env.NOW }} + labels: | + org.opencontainers.image.vendor="K/F Labs" \ + org.opencontainers.image.authors="protocol@k-f.co" \ + org.opencontainers.image.documentation="https://github.com/centrifuge/centrifuge-chain/blob/main/README.md" \ + org.opencontainers.image.base.name="ubuntu/jammy" \ + org.opencontainers.image.base.digest="ubuntu@sha256:6042500cf4b44023ea1894effe7890666b0c5c7871ed83a97c36c76ae560bb9b" - name: Configure GHA cache uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v6 diff --git a/docker/centrifuge-chain/Dockerfile b/docker/centrifuge-chain/Dockerfile index a9a7f08fe5..6f5d96b92d 100644 --- a/docker/centrifuge-chain/Dockerfile +++ b/docker/centrifuge-chain/Dockerfile @@ -29,23 +29,6 @@ FROM --platform=linux/amd64 docker.io/paritytech/ci-linux:production as builder FROM --platform=linux/amd64 docker.io/library/ubuntu:jammy ARG BUILD_DATE ARG VERSION - # Standard OCI labels - # https://github.com/opencontainers/image-spec/blob/main/annotations.md - LABEL io.centrifuge.image.vendor="Centrifuge" \ - org.opencontainers.image.created= \ - org.opencontainers.image.authors="protocol@k-f.co" \ - org.opencontainers.image.title="centrifugeio/centrifuge-chain" \ - org.opencontainers.image.description="Centrifuge, the layer 1 of RWA. This is the official Centrifuge (para)chain image" \ - org.opencontainers.image.source="https://github.com/centrifuge/centrifuge-chain/" \ - org.opencontainers.image.created="${BUILD_DATE}" \ - org.opencontainers.image.documentation="https://github.com/centrifuge/centrifuge-chain/blob/main/README.md" \ - org.opencontainers.image.version="$VERSION" \ - org.opencontainers.image.licenses="GPL-3" \ - org.opencontainers.image.base.name="ubuntu/jammy" \ - org.opencontainers.image.base.digest="ubuntu@sha256:6042500cf4b44023ea1894effe7890666b0c5c7871ed83a97c36c76ae560bb9b" - # org.opencontainers.image.url= \ - - RUN apt-get update && apt-get install -y curl jq RUN apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* @@ -57,6 +40,8 @@ FROM --platform=linux/amd64 docker.io/library/ubuntu:jammy COPY --from=builder /centrifuge-chain/target/release/centrifuge-chain /usr/local/bin/ COPY docker/scripts /centrifuge/scripts + # The following will make everything under /centrifuge/scripts reachable from PATH + # by creating a symbolic link into /usr/local/bin RUN chmod +x /centrifuge/scripts/* && \ ln -s /centrifuge/scripts/* /usr/local/bin/ diff --git a/docker/scripts/check-node-ready b/docker/scripts/check-node-ready deleted file mode 100644 index f31db3a081..0000000000 --- a/docker/scripts/check-node-ready +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -# Contact port 9933 and store the response -response=$(curl -s http://localhost:9933/health) - -# Extract the number of peers and the syncing status from the response -peers=$(echo "$response" | jq '.peers') -isSyncing=$(echo "$response" | jq '.isSyncing') - -# Check that the number of peers is more than 0 -if [ "$peers" -gt 0 ]; then - echo "Node has peers." -else - echo "Error: Node has no peers. Check the logs" - exit 1 -fi - -# Check that syncing is false -if [ "$isSyncing" == "false" ]; then - echo "Node is synched." -else - echo "Error: Node is still syncing but has peers. Check again later" - exit 1 -fi - -echo "Health check passed." -exit 0