Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

container: add container image version #3103

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .containerversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
26
61 changes: 41 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,45 @@ concurrency:
cancel-in-progress: true

env:
# Use alternative image when running on GitHub workflows CI to avoid potential
# rate limiting when executing jobs in parallel: they can't cache docker images
# and always pull.
#
# To update this image, generate a personal token with write:packages scope
# on https://github.com/settings/tokens and authenticate yourself locally with
# "docker login ghcr.io -u <github-username>" using the
# newly generated token as password.
# Once logged in, tag an new image:
# docker tag shiftcrypto/bitbox-wallet-app:VERSION \
# ghcr.io/bitboxswiss/bitbox-wallet-app-ci:VERSION
# and push as usual:
# docker push ghcr.io/bitboxswiss/bitbox-wallet-app-ci:VERSION
# Lastly, update the next line to use the newly pushed image version.
# See docs for more details:
# https://docs.github.com/en/packages/guides/pushing-and-pulling-docker-images
#
# Keep this in sync with default in scripts/github-ci.sh.
CI_IMAGE: ghcr.io/bitboxswiss/bitbox-wallet-app-ci:26
GITHUB_BUILD_DIR: ${{github.workspace}}

jobs:
setup-env:
runs-on: ubuntu-22.04
outputs:
ci_image: ${{ steps.set-ci-image.outputs.ci_image }}
steps:
- name: Clone the repo
uses: actions/checkout@v4

- name: Read CI Image Version
id: set-ci-image
run: |
# Use alternative image when running on GitHub workflows CI to avoid potential
# rate limiting when executing jobs in parallel: they can't cache docker images
# and always pull.
#
# To update this image, generate a personal token with write:packages scope
# on https://github.com/settings/tokens and authenticate yourself locally with
# "docker login ghcr.io -u <github-username>" using the
# newly generated token as password.
# Once logged in, tag an new image:
# docker tag shiftcrypto/bitbox-wallet-app:VERSION \
# ghcr.io/bitboxswiss/bitbox-wallet-app-ci:VERSION
# and push as usual:
# docker push ghcr.io/bitboxswiss/bitbox-wallet-app-ci:VERSION
# Lastly, update the next line to use the newly pushed image version.
# See docs for more details:
# https://docs.github.com/en/packages/guides/pushing-and-pulling-docker-images
#
# Keep this in sync with default in scripts/github-ci.sh.
CI_IMAGE_VERSION=$(cat .containerversion)
echo "CI_IMAGE=ghcr.io/bitboxswiss/bitbox-wallet-app-ci:$CI_IMAGE_VERSION" >> $GITHUB_ENV
echo "::set-output name=ci_image::ghcr.io/bitboxswiss/bitbox-wallet-app-ci:$CI_IMAGE_VERSION"

test-lint:
runs-on: ubuntu-22.04
needs: setup-env
steps:
- name: Clone the repo
with:
Expand All @@ -42,8 +57,11 @@ jobs:
run: ./scripts/github-ci.sh ci
env:
OS_NAME: linux
CI_IMAGE: ${{ needs.setup-env.outputs.ci_image }}

android:
runs-on: ubuntu-22.04
needs: setup-env
outputs:
artifact-url: ${{ steps.upload.outputs.artifact-url }}
steps:
Expand All @@ -60,6 +78,7 @@ jobs:
run: ./scripts/github-ci.sh android
env:
OS_NAME: linux
CI_IMAGE: ${{ needs.setup-env.outputs.ci_image }}
- name: Upload APK
id: upload
uses: actions/upload-artifact@v4
Expand All @@ -69,6 +88,7 @@ jobs:
if-no-files-found: error
qt-linux:
runs-on: ubuntu-22.04
needs: setup-env
outputs:
artifact-url-ai: ${{ steps.upload-ai.outputs.artifact-url }}
artifact-url-deb: ${{ steps.upload-deb.outputs.artifact-url }}
Expand All @@ -82,6 +102,7 @@ jobs:
run: ./scripts/github-ci.sh qt-linux
env:
OS_NAME: linux
CI_IMAGE: ${{ needs.setup-env.outputs.ci_image }}
- name: Upload AppImage
id: upload-ai
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -193,7 +214,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
with:
submodules: recursive
- name: Install Node.js
uses: actions/setup-node@v4
Expand Down
17 changes: 8 additions & 9 deletions scripts/dockerdev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
CONTAINER_VERSION="$(cat $DIR/../.containerversion)"

if [ -n "$CONTAINER_RUNTIME" ]; then
RUNTIME="$CONTAINER_RUNTIME"
Expand All @@ -25,11 +26,7 @@ fi

dockerdev () {
local container_name=bitbox-wallet-dev

if ! $RUNTIME images | grep -q bitbox-wallet-app; then
echo "No bitbox-wallet docker image found! Maybe you need to run 'make dockerinit'?" >&2
exit 1
fi
local image_name=shiftcrypto/bitbox-wallet-app

USERFLAG=""
if [ "$RUNTIME" = "docker" ] ; then
Expand All @@ -38,13 +35,15 @@ dockerdev () {
fi

# If already running, enter the container.
if $RUNTIME ps | grep -q $container_name; then
if $RUNTIME ps | grep $image_name:$CONTAINER_VERSION | grep -q $container_name; then
$RUNTIME exec $USERFLAG -it $container_name /opt/go/src/github.com/BitBoxSwiss/bitbox-wallet-app/scripts/docker_init.sh
return
fi

if $RUNTIME ps -a | grep -q $container_name; then
$RUNTIME rm $container_name
# A container based on a different image version is running. Let's stop and remove it.
if $RUNTIME ps | grep -q $container_name; then
$RUNTIME stop $container_name
$RUNTIME rm $container_name
fi

local repo_path="$DIR/.."
Expand All @@ -58,7 +57,7 @@ dockerdev () {
--add-host="dev1.shiftcrypto.ch:176.9.28.155" \
--add-host="dev2.shiftcrypto.ch:176.9.28.156" \
-v "$repo_path":/opt/go/src/github.com/BitBoxSwiss/bitbox-wallet-app \
shiftcrypto/bitbox-wallet-app bash
$image_name:$CONTAINER_VERSION bash

if [ "$RUNTIME" = "docker" ] ; then
# Use same user/group id as on the host, so that files are not created as root in the
Expand Down
Loading