Skip to content

Commit

Permalink
Allow VM_ID as input to docker publish job (#1278)
Browse files Browse the repository at this point in the history
* rename e upgrade to etna

* docker stuff

* fix

* fix

* fix

* move to workflow_dispatch

---------

Co-authored-by: Ceyhun Onur <ceyhun.onur@avalabs.org>
  • Loading branch information
darioush and ceyonur authored Aug 13, 2024
1 parent 46e869a commit 1bba2c8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/publish_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ name: Publish Docker Image

on:
workflow_dispatch:
inputs:
vm_id:
description: 'The ID of the VM (binary dst in Docker image)'
default: ''
required: false
type: string

push:
tags:
- "*"
branches:
- master


jobs:
publish_docker_image:
name: Publish Docker Image
Expand All @@ -19,4 +27,4 @@ jobs:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
DOCKER_REPO: "avaplatform/subnet-evm"
run: .github/workflows/publish_docker_image.sh
run: .github/workflows/publish_docker_image.sh ${{ inputs.vm_id }}
5 changes: 5 additions & 0 deletions .github/workflows/publish_docker_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ SUBNET_EVM_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd ../.. && pwd )
# Load the versions
source "$SUBNET_EVM_PATH"/scripts/versions.sh

# Set the vm id if provided
if [[ $# -eq 1 ]]; then
VM_ID=$1
fi

# Buld the docker image
source "$SUBNET_EVM_PATH"/scripts/build_docker_image.sh

Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ RUN export SUBNET_EVM_COMMIT=$SUBNET_EVM_COMMIT && export CURRENT_BRANCH=$CURREN
FROM avaplatform/avalanchego:$AVALANCHE_VERSION AS builtImage

# Copy the evm binary into the correct location in the container
COPY --from=builder /build/build/subnet-evm /avalanchego/build/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy
ARG VM_ID
COPY --from=builder /build/build/subnet-evm /avalanchego/build/plugins/$VM_ID
11 changes: 9 additions & 2 deletions scripts/build_docker_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ source "$SUBNET_EVM_PATH"/scripts/versions.sh

# WARNING: this will use the most recent commit even if there are un-committed changes present
BUILD_IMAGE_ID=${BUILD_IMAGE_ID:-"${CURRENT_BRANCH}"}
DOCKERHUB_TAG=${SUBNET_EVM_COMMIT::8}

VM_ID=${VM_ID:-"${DEFAULT_VM_ID}"}
if [[ "${VM_ID}" != "${DEFAULT_VM_ID}" ]]; then
DOCKERHUB_TAG="${VM_ID}-${DOCKERHUB_TAG}"
fi

echo "Building Docker Image: $DOCKERHUB_REPO:$BUILD_IMAGE_ID based of AvalancheGo@$AVALANCHE_VERSION"
docker build -t "$DOCKERHUB_REPO:$BUILD_IMAGE_ID" -t "$DOCKERHUB_REPO:${SUBNET_EVM_COMMIT::8}" \
docker build -t "$DOCKERHUB_REPO:$BUILD_IMAGE_ID" -t "$DOCKERHUB_REPO:${DOCKERHUB_TAG}" \
"$SUBNET_EVM_PATH" -f "$SUBNET_EVM_PATH/Dockerfile" \
--build-arg AVALANCHE_VERSION="$AVALANCHE_VERSION" \
--build-arg SUBNET_EVM_COMMIT="$SUBNET_EVM_COMMIT" \
--build-arg CURRENT_BRANCH="$CURRENT_BRANCH"
--build-arg CURRENT_BRANCH="$CURRENT_BRANCH" \
--build-arg VM_ID="$VM_ID"

0 comments on commit 1bba2c8

Please sign in to comment.