diff --git a/.gitignore b/.gitignore index d19bbc7..5bafd17 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ dev /ci/bin/*dev* .vagrant hack/* -!hack/run.sh \ No newline at end of file +!hack/run.sh +!hack/build_push.sh \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1da1090..a0fef36 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -78,6 +78,31 @@ vagrant rsync vagrant rsync-auto ``` +#### 3. Deploy development version to K8s cluster + +Deployment provides a good environment for: +- Final testing in a real world scenario +- Run the final version until included in a release + +> [!Note] +> Make sure to do the build on the architecture you will be running it. +> For example, don't build in Apple Silicon if your cluster runs in amd64. + + +1. Login to your github container registry +```bash +docker login ghcr.io +``` + +> [!Important] +> Login to the container registry is stored plain text, use a PAT instead of your Github password. [Create a PAT with write:packages](https://github.com/settings/tokens/new?scopes=write:packages). + +2. Compile and push to your github container registry. +```bash +./hack/build_push.sh +``` +2. + ### Best Practices - Use devcontainer for day-to-day development and coding diff --git a/hack/build_push.sh b/hack/build_push.sh new file mode 100644 index 0000000..609bd28 --- /dev/null +++ b/hack/build_push.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e +set -x + +ROOT_DIR="$(dirname "$(realpath "$0")")" + +GITHUB_USER=${GITHUB_USER:-$(jq -r '.auths."ghcr.io".auth' ~/.docker/config.json|base64 -d|cut -d':' -f1)} +GITHUB_REPO=${GITHUB_REPO:-$(basename -s ${ROOT_DIR}/../.git $(git remote get-url origin))} +DOCKER_TAG=${DOCKER_TAG:-$(git branch --show-current)-$(git rev-parse --short HEAD)} + +if [ -z "${GITHUB_USER}" ]; then + echo "Error: Need to login to ghcr.io ; execute docker login ghcr.io" + exit 1 +fi + +docker build $ROOT_DIR/.. --push -t ghcr.io/${GITHUB_USER}/${GITHUB_REPO}:${DOCKER_TAG} +echo "Image pushed to ghcr.io/${GITHUB_USER}/${GITHUB_REPO}:${DOCKER_TAG}" \ No newline at end of file