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

Consider pushing image also to ghcr.io #35

Open
troglobit opened this issue Oct 26, 2022 · 4 comments
Open

Consider pushing image also to ghcr.io #35

troglobit opened this issue Oct 26, 2022 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@troglobit
Copy link

Hi!

We have a few Zephyr/nRF related repositories, one of them is a private repo. for the end customer firmware. When we tag a release there we'd like to have everything needed to rebuild/patch/fix from that tag a few years down the line, relying on our GitHub action to rebuild with the same build deps used when we created the tag.

This nrf-docker project looks exactly like what I wanted to set up myself. Have you considered pushing the resulting Docker images also to the GitHub Container Repository, ghcr.io? This would greatly speed up download and build times for GitHub actions.

If you're interested, here's an example of what I did to automate our pandoc docker image to push to ghcr.io:

name: Pandoc Docker Container

on:
  push:
    branches:
      - 'main'
    tags:
      - 'v*'
    paths:
      - 'Dockerfile'
  workflow_dispatch:

env:
  IMAGE_NAME: pandoc

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      packages: write
      contents: read
    steps:
      - uses: actions/checkout@v2
      - name: Build image
        run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
      - name: Log in to registry
        run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
      - name: Push image
        run: |
          IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
          # Change all uppercase to lowercase
          IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
          # Strip git ref prefix from version
          VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
          # Use Docker `latest` tag convention
          [ "$VERSION" == "main" ] && VERSION=latest
          echo IMAGE_ID=$IMAGE_ID
          echo VERSION=$VERSION
          docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
          docker push $IMAGE_ID:$VERSION

Cheers
/Joachim

@coderbyheart
Copy link
Member

Sounds good! I also have GitHub Actions, however the download speed has not yet been an issue for me. However it takes 2m 23s in one of my projects so this sounds like a good idea!

@coderbyheart
Copy link
Member

Realized that I don't have the permission to make the published image public right now, so I've reverted above change.

@troglobit
Copy link
Author

Yeah noticed, I was surprised you got to it so quickly. I'll continue with other things meanwhile, entropy and all that ... looking forward to having it on ghcr eventually 🙏

@troglobit troglobit closed this as not planned Won't fix, can't repro, duplicate, stale Nov 11, 2023
@coderbyheart coderbyheart reopened this Apr 12, 2024
@coderbyheart
Copy link
Member

We have now the permission to publish to https://github.com/orgs/NordicPlayground/packages?repo_name=nrf-docker, so I'll look into this soon™️.

@coderbyheart coderbyheart added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed and removed on hold labels Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants