This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Finalize docker build script #693
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Publish Docker Container Images | ||
on: | ||
push: | ||
branches: [main] | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
Per-SHA-Image: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: build | ||
env: | ||
PLATFORMS: linux/amd64,linux/arm64 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build Corso Binaries | ||
run: > | ||
./build.sh | ||
--platforms ${{ env.PLATFORMS }} | ||
|
||
# - name: Build Corso Binaries Locally | ||
# run: > | ||
# ./multiplatform-binary.sh | ||
# --platforms ${{ env.PLATFORMS }} | ||
|
||
# apparently everyone uses this step | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
# setup Docker buld action | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
# retrieve credentials for ghcr.io | ||
- name: Login to Github Packages | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# deploy the image | ||
- name: Build image and push to GitHub Container Registry | ||
env: | ||
sha: git_hash=$(git rev-parse --short "$GITHUB_SHA") | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: ./build/Dockerfile | ||
platforms: ${{ env.PLATFORMS }} | ||
push: true | ||
tags: ghcr.io/alcionai/corso:${{ env.sha }} | ||
# use the github cache | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
# check the image digest | ||
- name: Image digest | ||
run: echo ${{ steps.docker_build.outputs.digest }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
SCRIPT_ROOT=$(dirname $(readlink -f $0)) | ||
PROJECT_ROOT=$(dirname ${SCRIPT_ROOT}) | ||
|
||
platforms= | ||
GOVER=1.18 | ||
GOOS=linux | ||
GOARCH=amd64 | ||
|
||
while [ "$#" -gt 0 ] | ||
do | ||
case "$1" in | ||
--platforms) | ||
platforms=$2 | ||
shift | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
CORSO_BUILD_ARGS="$@" | ||
|
||
if [ -z "$platforms" ]; then | ||
platforms="${GOOS}/${GOARCH}" | ||
fi | ||
|
||
for platform in ${platforms/,/ } | ||
do | ||
IFS='/' read -r -a platform_split <<< "${platform}" | ||
GOOS=${platform_split[0]} | ||
GOARCH=${platform_split[1]} | ||
|
||
echo "-----" | ||
echo "building corso binary for ${GOOS}/${GOARCH}" | ||
echo "-----" | ||
|
||
OS_ARCH_DIR=${PROJECT_ROOT}/bin/${GOOS}-${GOARCH} | ||
|
||
set -x | ||
|
||
mkdir -p ${OS_ARCH_DIR} | ||
|
||
cd ${PROJECT_ROOT}/src; \ | ||
GOOS=${GOOS} \ | ||
GOARCH=${GOARCH} \ | ||
go build -o ${OS_ARCH_DIR} "$CORSO_BUILD_ARGS" | ||
|
||
set +x | ||
|
||
echo "-----" | ||
echo "created binary ${PROJECT_ROOT}/bin/${GOOS}-${GOARCH}/corso" | ||
echo "-----" | ||
done |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the plan to switch to
multiplatform-binary.sh
here before merge?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not at this time, due to the cross-platform build failures, seen here. We're unable to use that script in CI deployment, unless we connive some way around it. I should actually remove that commented section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me why this doesn't hit the same issue - we're still cross-compiling when running
build
in the golang container - right? Also - this discussion is not a blocker for the PR which I've approved.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted. And, yeah, it isn't apparent to me either. Likewise, my local build doesn't have the same issue. Taking shots in the dark here, but I suppose the container could have some built-in emulation to help it along in some way. I'd expect github's ubuntu-latest runtime to have similar. But it's difficult to know.