From 47bf5d6427776dee2838c61ca6231140a59a1aa2 Mon Sep 17 00:00:00 2001 From: tsubramanian Date: Wed, 24 Jul 2024 19:33:48 -0400 Subject: [PATCH 01/15] Create docker-image.yml --- .github/workflows/docker-image.yml | 89 ++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..4edc1d6 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,89 @@ +name: Build and upload Docker + +on: + push: + branches: + - git-build + tags: + - v* + schedule: + - cron: '0 0 * * *' # Every day at midnight + +jobs: + devops: + name: Docker image build + runs-on: ubuntu-latest + permissions: + packages: write + strategy: + matrix: + images: + - scout + + steps: + - uses: actions/checkout@v2 + if: github.event_name == 'schedule' + with: + ref: git-build + + - uses: actions/checkout@v2 + if: github.event_name != 'schedule' + + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: 3.8 + + - name: Free Disk space + run: | + sudo swapoff -a + sudo rm -f /swapfile + sudo rm -rf /opt/hostedtoolcache + sudo apt clean + docker rmi $(docker image ls -aq) + df -h + + # Build images + - name: Build images + run: | + # Build Image + cd devops/ + bash build.sh ${{ matrix.images }} + env: + # The wildbook-ia image is built at the same time as wbia, it is an alias + BUILD_IMAGES: ${{ matrix.images }} + + # Log into image registries + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: wildmeorg + password: ${{ secrets.WBIA_WILDMEBOT_DOCKER_HUB_TOKEN }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GHCR_PAT }} + + - name: Push to Docker Hub (Latest) + if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }} + run: | + VERSION=$(echo ${GITHUB_REF} | sed 's#.*/v##') + bash devops/publish.sh -t ${VERSION} ${PUBLISH_IMAGES} + bash devops/publish.sh -t latest ${PUBLISH_IMAGES} + env: + PUBLISH_IMAGES: ${{ matrix.images }} wildbook-ia + + # Push containers out to container registries + - name: Push to GitHub Packages (Latest) + if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }} + run: | + VERSION=$(echo ${GITHUB_REF} | sed 's#.*/v##') + bash devops/publish.sh -t ${VERSION} -r ghcr.io/wildmeorg/wildbook-ia ${PUBLISH_IMAGES} + bash devops/publish.sh -t latest -r ghcr.io/wildmeorg/wildbook-ia ${PUBLISH_IMAGES} + env: + PUBLISH_IMAGES: ${{ matrix.images }} wildbook-ia + + From 413e961031f974e48bfaa9e7ea51fdade7416fe8 Mon Sep 17 00:00:00 2001 From: tsubramanian Date: Wed, 24 Jul 2024 19:35:27 -0400 Subject: [PATCH 02/15] Create publish.sh --- publish.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 publish.sh diff --git a/publish.sh b/publish.sh new file mode 100644 index 0000000..faff749 --- /dev/null +++ b/publish.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +set -e + +usage () { + echo "Usage: $0 [-t ] [-r ] [ ...]"; +} + +# Parse commandline options +while getopts ":t:r:" option; do + case ${option} in + t ) TAG=${OPTARG};; + r ) REGISTRY=${OPTARG};; + \? ) usage; exit 1;; + esac +done +shift $((OPTIND - 1)) + +# Assign variables +TAG=${TAG:-latest} +REGISTRY=${REGISTRY:-} +IMAGES=${@:-scout} +# Set the image prefix +if [ -n "$REGISTRY" ]; then + IMG_PREFIX="${REGISTRY}/" +else + IMG_PREFIX="wildme/" +fi + +# Tag built images from `build.sh`, which tags as `latest` +for IMG in $IMAGES; do + echo "Tagging scout/${IMG}:latest --> ${IMG_PREFIX}${IMG}:${TAG}" + docker tag wildme/${IMG}:latest ${IMG_PREFIX}${IMG}:${TAG} + echo "Pushing ${IMG_PREFIX}${IMG}:${TAG}" + docker push ${IMG_PREFIX}${IMG}:${TAG} +done From c49f33c539f12fb94eaa5f92b99d20e7877e2117 Mon Sep 17 00:00:00 2001 From: tsubramanian Date: Wed, 24 Jul 2024 19:37:23 -0400 Subject: [PATCH 03/15] Create build.sh --- build.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..b5c5643 --- /dev/null +++ b/build.sh @@ -0,0 +1,20 @@ +export DOCKER_BUILDKIT=1 + +export DOCKER_CLI_EXPERIMENTAL=enabled + +# Change to the script's root directory location +cd ${ROOT_LOC} + +# Build the images in dependence order +while [ $# -ge 1 ]; do + if [ "$1" == "scout" ]; then + docker build \ + --compress \ + -t wildme/scout:latest \ + --no-cache + else + echo "Image $1 not found" + exit 1 + fi + shift +done From 5cb5972f0897979fd15790f7f7ac2fe83b3ab742 Mon Sep 17 00:00:00 2001 From: tsubramanian Date: Wed, 24 Jul 2024 19:40:25 -0400 Subject: [PATCH 04/15] Update docker-image.yml --- .github/workflows/docker-image.yml | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 4edc1d6..7064dc9 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -4,10 +4,6 @@ on: push: branches: - git-build - tags: - - v* - schedule: - - cron: '0 0 * * *' # Every day at midnight jobs: devops: @@ -26,14 +22,6 @@ jobs: with: ref: git-build - - uses: actions/checkout@v2 - if: github.event_name != 'schedule' - - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: 3.8 - - name: Free Disk space run: | sudo swapoff -a @@ -47,7 +35,6 @@ jobs: - name: Build images run: | # Build Image - cd devops/ bash build.sh ${{ matrix.images }} env: # The wildbook-ia image is built at the same time as wbia, it is an alias @@ -68,22 +55,13 @@ jobs: password: ${{ secrets.GHCR_PAT }} - name: Push to Docker Hub (Latest) - if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }} + if: ${{ github.event_name == 'push' }} run: | VERSION=$(echo ${GITHUB_REF} | sed 's#.*/v##') - bash devops/publish.sh -t ${VERSION} ${PUBLISH_IMAGES} - bash devops/publish.sh -t latest ${PUBLISH_IMAGES} + bash publish.sh -t ${VERSION} ${PUBLISH_IMAGES} + bash publish.sh -t latest ${PUBLISH_IMAGES} env: - PUBLISH_IMAGES: ${{ matrix.images }} wildbook-ia + PUBLISH_IMAGES: ${{ matrix.images }} scout - # Push containers out to container registries - - name: Push to GitHub Packages (Latest) - if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }} - run: | - VERSION=$(echo ${GITHUB_REF} | sed 's#.*/v##') - bash devops/publish.sh -t ${VERSION} -r ghcr.io/wildmeorg/wildbook-ia ${PUBLISH_IMAGES} - bash devops/publish.sh -t latest -r ghcr.io/wildmeorg/wildbook-ia ${PUBLISH_IMAGES} - env: - PUBLISH_IMAGES: ${{ matrix.images }} wildbook-ia From 11a41f13b82e5f9328257ada822611d0273133d6 Mon Sep 17 00:00:00 2001 From: tsubramanian Date: Wed, 24 Jul 2024 19:42:48 -0400 Subject: [PATCH 05/15] Update docker-image.yml --- .github/workflows/docker-image.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 7064dc9..02e757b 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -35,7 +35,7 @@ jobs: - name: Build images run: | # Build Image - bash build.sh ${{ matrix.images }} + bash ./build.sh ${{ matrix.images }} env: # The wildbook-ia image is built at the same time as wbia, it is an alias BUILD_IMAGES: ${{ matrix.images }} @@ -58,8 +58,7 @@ jobs: if: ${{ github.event_name == 'push' }} run: | VERSION=$(echo ${GITHUB_REF} | sed 's#.*/v##') - bash publish.sh -t ${VERSION} ${PUBLISH_IMAGES} - bash publish.sh -t latest ${PUBLISH_IMAGES} + bash ./publish.sh -t latest ${PUBLISH_IMAGES} env: PUBLISH_IMAGES: ${{ matrix.images }} scout From e3549724f2cf3adeff1aa3ad3785e3a83dc79f2d Mon Sep 17 00:00:00 2001 From: tsubramanian Date: Wed, 24 Jul 2024 19:45:08 -0400 Subject: [PATCH 06/15] Update docker-image.yml --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 02e757b..87eb512 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v2 - if: github.event_name == 'schedule' + if: github.event_name == 'push' with: ref: git-build From 7050e00a1fd26de9a60f1f47e9b1ccd5600235ab Mon Sep 17 00:00:00 2001 From: tsubramanian Date: Wed, 24 Jul 2024 19:52:46 -0400 Subject: [PATCH 07/15] Update build.sh --- build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index b5c5643..41bcdc4 100644 --- a/build.sh +++ b/build.sh @@ -11,7 +11,8 @@ while [ $# -ge 1 ]; do docker build \ --compress \ -t wildme/scout:latest \ - --no-cache + --no-cache \ + . else echo "Image $1 not found" exit 1 From b8221728056540280a5dad17328f7b2daa4ef01f Mon Sep 17 00:00:00 2001 From: tsubramanian Date: Wed, 24 Jul 2024 19:55:26 -0400 Subject: [PATCH 08/15] Update docker-image.yml --- .github/workflows/docker-image.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 87eb512..e6f02ec 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -22,20 +22,11 @@ jobs: with: ref: git-build - - name: Free Disk space - run: | - sudo swapoff -a - sudo rm -f /swapfile - sudo rm -rf /opt/hostedtoolcache - sudo apt clean - docker rmi $(docker image ls -aq) - df -h - # Build images - name: Build images run: | # Build Image - bash ./build.sh ${{ matrix.images }} + bash build.sh ${{ matrix.images }} env: # The wildbook-ia image is built at the same time as wbia, it is an alias BUILD_IMAGES: ${{ matrix.images }} @@ -58,7 +49,7 @@ jobs: if: ${{ github.event_name == 'push' }} run: | VERSION=$(echo ${GITHUB_REF} | sed 's#.*/v##') - bash ./publish.sh -t latest ${PUBLISH_IMAGES} + bash publish.sh -t latest ${PUBLISH_IMAGES} env: PUBLISH_IMAGES: ${{ matrix.images }} scout From f69095996b0e2edfb19dcedd34c9f20b438a4fa4 Mon Sep 17 00:00:00 2001 From: tsubramanian Date: Wed, 24 Jul 2024 20:00:01 -0400 Subject: [PATCH 09/15] Update docker-image.yml --- .github/workflows/docker-image.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index e6f02ec..3c6669f 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -26,10 +26,7 @@ jobs: - name: Build images run: | # Build Image - bash build.sh ${{ matrix.images }} - env: - # The wildbook-ia image is built at the same time as wbia, it is an alias - BUILD_IMAGES: ${{ matrix.images }} + bash ./build.sh ${{ matrix.images }} # Log into image registries - name: Login to DockerHub @@ -49,7 +46,7 @@ jobs: if: ${{ github.event_name == 'push' }} run: | VERSION=$(echo ${GITHUB_REF} | sed 's#.*/v##') - bash publish.sh -t latest ${PUBLISH_IMAGES} + bash ./publish.sh -t latest ${PUBLISH_IMAGES} env: PUBLISH_IMAGES: ${{ matrix.images }} scout From af1c76e756dc76e520578ee59f13e732cc0b211e Mon Sep 17 00:00:00 2001 From: tsubramanian Date: Wed, 24 Jul 2024 20:04:27 -0400 Subject: [PATCH 10/15] Update build.sh --- build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.sh b/build.sh index 41bcdc4..5f32bd8 100644 --- a/build.sh +++ b/build.sh @@ -8,6 +8,8 @@ cd ${ROOT_LOC} # Build the images in dependence order while [ $# -ge 1 ]; do if [ "$1" == "scout" ]; then + echo "PWD::" + echo pwd docker build \ --compress \ -t wildme/scout:latest \ From deb6e60da5d0807379575678c248000ce9a22055 Mon Sep 17 00:00:00 2001 From: tsubramanian Date: Wed, 24 Jul 2024 20:06:45 -0400 Subject: [PATCH 11/15] Update build.sh --- build.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 5f32bd8..39d99c8 100644 --- a/build.sh +++ b/build.sh @@ -8,8 +8,7 @@ cd ${ROOT_LOC} # Build the images in dependence order while [ $# -ge 1 ]; do if [ "$1" == "scout" ]; then - echo "PWD::" - echo pwd + echo "Current working directory: $PWD" docker build \ --compress \ -t wildme/scout:latest \ From 7f0a3be049a02a469bbcf3b03381450d1caefae7 Mon Sep 17 00:00:00 2001 From: tsubramanian Date: Wed, 24 Jul 2024 20:11:02 -0400 Subject: [PATCH 12/15] Update build.sh --- build.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.sh b/build.sh index 39d99c8..f5000a7 100644 --- a/build.sh +++ b/build.sh @@ -1,3 +1,8 @@ +#!/usr/bin/env bash + +# See https://stackoverflow.com/a/246128/176882 +export ROOT_LOC="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + export DOCKER_BUILDKIT=1 export DOCKER_CLI_EXPERIMENTAL=enabled From 2de41542c796a54edd8039618460f37707dfd939 Mon Sep 17 00:00:00 2001 From: tsubramanian Date: Wed, 24 Jul 2024 20:19:09 -0400 Subject: [PATCH 13/15] Update docker-image.yml --- .github/workflows/docker-image.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 3c6669f..91dec6e 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -22,6 +22,15 @@ jobs: with: ref: git-build + - name: Free Disk space + run: | + sudo swapoff -a + sudo rm -f /swapfile + sudo rm -rf /opt/hostedtoolcache + sudo apt clean + docker rmi $(docker image ls -aq) + df -h + # Build images - name: Build images run: | From 015524b028ab40cca6889f792ca1b8c3756c9227 Mon Sep 17 00:00:00 2001 From: tsubramanian Date: Wed, 24 Jul 2024 20:34:06 -0400 Subject: [PATCH 14/15] Update docker-image.yml --- .github/workflows/docker-image.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 91dec6e..a6c4263 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,4 +1,4 @@ -name: Build and upload Docker +name: Build and upload Docker for Scout on: push: @@ -44,13 +44,6 @@ jobs: username: wildmeorg password: ${{ secrets.WBIA_WILDMEBOT_DOCKER_HUB_TOKEN }} - - name: Login to GitHub Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GHCR_PAT }} - - name: Push to Docker Hub (Latest) if: ${{ github.event_name == 'push' }} run: | From c83c27579870bf9eeed39e4053bfef1fb67cafc6 Mon Sep 17 00:00:00 2001 From: tsubramanian Date: Wed, 24 Jul 2024 22:30:04 -0400 Subject: [PATCH 15/15] Update docker-image.yml --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index a6c4263..d8d515f 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -3,7 +3,7 @@ name: Build and upload Docker for Scout on: push: branches: - - git-build + - main jobs: devops: @@ -14,7 +14,7 @@ jobs: strategy: matrix: images: - - scout + - main steps: - uses: actions/checkout@v2