From e01bf551b5f62ba7b52e03314af85329b99e2f51 Mon Sep 17 00:00:00 2001 From: AshtonStephens Date: Thu, 24 Oct 2024 13:56:50 +0100 Subject: [PATCH] test: try to deploy docker images to dockerhub --- .github/actions/dockerfiles/Dockerfile.debian | 2 +- .../dockerfiles/Dockerfile.test.debian | 13 ++++++ .github/workflows/image-build.yaml | 43 +++++++++++-------- 3 files changed, 39 insertions(+), 19 deletions(-) create mode 100644 .github/actions/dockerfiles/Dockerfile.test.debian diff --git a/.github/actions/dockerfiles/Dockerfile.debian b/.github/actions/dockerfiles/Dockerfile.debian index a13920b40..9b856fb9a 100644 --- a/.github/actions/dockerfiles/Dockerfile.debian +++ b/.github/actions/dockerfiles/Dockerfile.debian @@ -1,4 +1,4 @@ -FROM rust:1.81-slim-bookworm as build +FROM rust:1.81.0-slim-bookworm as build # Install dependencies. RUN apt-get update diff --git a/.github/actions/dockerfiles/Dockerfile.test.debian b/.github/actions/dockerfiles/Dockerfile.test.debian new file mode 100644 index 000000000..8412b2a84 --- /dev/null +++ b/.github/actions/dockerfiles/Dockerfile.test.debian @@ -0,0 +1,13 @@ +FROM rust:1.81.0-slim-bookworm as build + +# Create Docker image to run the emily server. +FROM debian:bookworm-slim AS emily-server +ENTRYPOINT ["echo", "Hello World from the emily-server!"] + +# Create Docker image to run the signer. +FROM debian:bookworm-slim AS signer +ENTRYPOINT ["echo", "Hello World from the signer!"] + +# Create Docker image to run the blocklist client. +FROM debian:bookworm-slim AS blocklist-client +ENTRYPOINT ["echo", "Hello World from the blocklist-client!"] diff --git a/.github/workflows/image-build.yaml b/.github/workflows/image-build.yaml index f3e0c9574..8cd2d15d2 100644 --- a/.github/workflows/image-build.yaml +++ b/.github/workflows/image-build.yaml @@ -17,7 +17,7 @@ on: ## Define which docker arch to build for env: # docker_platforms: "linux/arm64, linux/amd64, linux/arm/v7, linux/amd64/v3, linux/arm64/v8" - docker_platforms: "linux/arm64" + docker_platforms: "linux/amd64" docker-org: blockstack concurrency: @@ -51,17 +51,24 @@ jobs: id: docker_setup uses: stacks-network/actions/docker@main with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} + username: ${{ secrets.ASHTON_DOCKERHUB_USERNAME }} + password: ${{ secrets.ASHTON_DOCKERHUB_PASSWORD }} + + # ## if the repo owner is not `stacks-network`, default to a docker-org of the repo owner (i.e. github user id) + # ## this allows forks to run the docker push workflows without having to hardcode a dockerhub org (but it does require docker hub user to match github username) + # - name: Set Local env vars + # id: set_env + # if: | + # github.repository_owner != 'stacks-network' + # run: | + # echo "docker-org=${{ github.repository_owner }}" >> "$GITHUB_ENV" - ## if the repo owner is not `stacks-network`, default to a docker-org of the repo owner (i.e. github user id) - ## this allows forks to run the docker push workflows without having to hardcode a dockerhub org (but it does require docker hub user to match github username) - name: Set Local env vars id: set_env - if: | - github.repository_owner != 'stacks-network' run: | - echo "docker-org=${{ github.repository_owner }}" >> "$GITHUB_ENV" + echo "docker-org=ashtontm" >> "$GITHUB_ENV" + echo "rc-version=0.0.1" >> "$GITHUB_ENV" + echo "docker-repo=test" >> "$GITHUB_ENV" ## Set docker metatdata ## - depending on the matrix.dist, different tags will be enabled @@ -71,31 +78,31 @@ jobs: uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 #v5.5.1 with: ## tag images with current repo name `stacks-core` as well as legacy `stacks-blockchain` - # ${{env.docker-org}}/${{ github.event.repository.name }}/${{ matrix.docker_target }} + # ${{env.docker-org}}/${{ github.event.repository.name }} images: | - ${{env.docker-org}}/sbtc/${{ matrix.docker_target }} + ${{env.docker-org}}/${{env.docker-repo}} tags: | - type=raw,value=latest,enable=${{ secrets.TEST_DOCKER_IMAGE_TAG != '' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ) && matrix.dist == 'debian' }} - type=raw,value=${{ secrets.TEST_DOCKER_IMAGE_TAG }}-${{ matrix.dist }},enable=${{ secrets.TEST_DOCKER_IMAGE_TAG != '' && matrix.dist == 'debian'}} - type=raw,value=${{ secrets.TEST_DOCKER_IMAGE_TAG }},enable=${{ secrets.TEST_DOCKER_IMAGE_TAG != '' && matrix.dist == 'debian' }} + type=raw,value=${{ matrix.docker_target }}-latest,enable=${{ matrix.docker_target != '' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ) && matrix.dist == 'debian' }} + type=raw,value=${{ matrix.docker_target }}-${{ env.rc-version }}-${{ matrix.dist }},enable=${{ matrix.docker_target != '' && matrix.dist == 'debian'}} + type=raw,value=${{ matrix.docker_target }}-${{ env.rc-version }},enable=${{ matrix.docker_target != '' && matrix.dist == 'debian' }} type=ref,event=tag,enable=${{ matrix.dist == 'debian' }} - type=raw,value=latest-${{ matrix.dist }},enable=${{ secrets.TEST_DOCKER_IMAGE_TAG != '' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ) && matrix.dist == 'alpine' }} - type=raw,value=${{ secrets.TEST_DOCKER_IMAGE_TAG }}-${{ matrix.dist }},enable=${{ secrets.TEST_DOCKER_IMAGE_TAG != '' && matrix.dist == 'alpine' }} + type=raw,value=${{ matrix.docker_target }}-latest-${{ matrix.dist }},enable=${{ matrix.docker_target != '' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ) && matrix.dist == 'alpine' }} + type=raw,value=${{ matrix.docker_target }}-${{ env.rc-version }}-${{ matrix.dist }},enable=${{ matrix.docker_target != '' && matrix.dist == 'alpine' }} ## Build docker image for release - name: Build and Push ( ${{matrix.dist}} ${{matrix.docker_target}} ) id: docker_build uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 with: - file: ./.github/actions/dockerfiles/Dockerfile.${{ matrix.dist }} + file: ./.github/actions/dockerfiles/Dockerfile.test.${{ matrix.dist }} platforms: ${{ env.docker_platforms }} tags: ${{ steps.docker_metadata.outputs.tags }} labels: ${{ steps.docker_metadata.outputs.labels }} target: ${{ matrix.docker_target }} build-args: | - TAG=${{ secrets.TEST_DOCKER_IMAGE_TAG }} + TAG=${{ matrix.docker_target }} REPO=${{ github.repository_owner }}/${{ github.event.repository.name }} - STACKS_NODE_VERSION=${{ secrets.TEST_DOCKER_IMAGE_TAG || env.GITHUB_SHA_SHORT }} + STACKS_NODE_VERSION=${{ matrix.docker_target || env.GITHUB_SHA_SHORT }} GIT_BRANCH=${{ env.GITHUB_REF_SHORT }} GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }} push: ${{ env.DOCKER_PUSH }}