Skip to content

Commit

Permalink
test: try to deploy docker images to dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
AshtonStephens committed Oct 24, 2024
1 parent a8699e5 commit e01bf55
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/actions/dockerfiles/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 13 additions & 0 deletions .github/actions/dockerfiles/Dockerfile.test.debian
Original file line number Diff line number Diff line change
@@ -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!"]
43 changes: 25 additions & 18 deletions .github/workflows/image-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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 }}

0 comments on commit e01bf55

Please sign in to comment.