Skip to content

Commit

Permalink
Added multi-cpu arch - fixed #6
Browse files Browse the repository at this point in the history
  • Loading branch information
githubsaturn committed Mar 31, 2024
1 parent 65f2fcd commit 14d89df
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/publish_master.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build and push Docker image

on:
push:
branches:
- master

jobs:
build-publish-docker-hub:
runs-on: ubuntu-latest
steps:
- uses: azure/docker-login@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- uses: actions/checkout@v1
- name: Build and Push Edge to DockerHub
shell: bash
run: ./dev-scripts/build_and_push.sh
41 changes: 41 additions & 0 deletions dev-scripts/build_and_push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# Exit early if any command fails
set -e

# Print all commands
set -x

pwd

# ensure you're not running it on local machine
if [ -z "$CI" ] || [ -z "$GITHUB_REF" ]; then
echo "Running on a local machine! Exiting!"
exit 127
else
echo "Running on CI"
fi

# BRANCH=$(git rev-parse --abbrev-ref HEAD)
# On Github the line above does not work, instead:
BRANCH=${GITHUB_REF##*/}
echo "on branch $BRANCH"
if [[ "$BRANCH" != "master" ]]; then
echo 'Not on master branch! Aborting script!'
exit 1
fi

git clean -fdx .

GIT_COMMIT_HASH=$(git rev-parse --short "$GITHUB_SHA")

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
export DOCKER_CLI_EXPERIMENTAL=enabled
docker buildx ls
docker buildx create --name mybuilder
docker buildx use mybuilder

IMAGE_NAME=caprover/nginx-redirect
IMAGE_VERSION=1-$GIT_COMMIT_HASH

docker buildx build --platform linux/amd64,linux/arm64,linux/arm -t $IMAGE_NAME:$IMAGE_VERSION -t $IMAGE_NAME:latest -f Dockerfile --push .

0 comments on commit 14d89df

Please sign in to comment.