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

Publish Docker images to GitHub Container Registry #440

Merged
merged 1 commit into from
Oct 14, 2024
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
4 changes: 3 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
indent_size = 2

[*.{yaml,yml}]
indent_size = 2

[*.{mj,cj,j,t}s]
Expand Down
35 changes: 17 additions & 18 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,18 @@ on:
- "v2.*"
workflow_dispatch:

env:
DOCKER_REGISTRY: ${{ github.repository_owner == 'hyperledger' && 'docker.io' || 'ghcr.io' }}

jobs:
test:
uses: ./.github/workflows/test.yaml

publishnpm:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
needs: test
steps:
- uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
- uses: actions/download-artifact@v4
with:
name: node-tgzs
Expand All @@ -37,43 +34,45 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

publishdocker:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why shift to ubuntu-24.04 for some and ubuntu-latest for others? Should probably keep it consistent.

Note that on fabric core we shifted everything to ubuntu-22.04 so that we'd have full control of the version and remain one level back to help with user compatibility (in case users can't yet support ubuntu-24.04 images, more important for things like fabric-ca which uses cgo in the binary build). I realize that these changes are just for the runners and not the final user image so I'm fine going to ubuntu-24.04 in this repository. Just wanted to provide you the thinking from core fabric in case you want to remain consistent with ubuntu-22.04.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

24.04 is the current LTS so it seemed to make sense to shift to that instead of 22.04. I used an explicit Ubuntu release for tests and other things where it might be helpful to specify the Ubuntu version used for testing. For jobs where the version doesn't really matter, I figured ubuntu-latest meant they would stay current with minimal maintenance, and likely have access to the largest pool of hosted runners.

needs: test
permissions:
contents: read
packages: write

strategy:
fail-fast: false
matrix:
DOCKER_REGISTRY:
- "docker.io"
- "ghcr.io"
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
config-inline: |
buildkitd-config-inline: |
[worker.oci]
max-parallelism = 1
- name: Checkout
uses: actions/checkout@v4

- name: Login to the ${{ env.DOCKER_REGISTRY }} Container Registry
- name: Login to the ${{ matrix.DOCKER_REGISTRY }} Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ env.DOCKER_REGISTRY == 'docker.io' && secrets.DOCKERHUB_USERNAME || github.actor }}
password: ${{ env.DOCKER_REGISTRY == 'docker.io' && secrets.DOCKERHUB_TOKEN || secrets.GITHUB_TOKEN }}

registry: ${{ matrix.DOCKER_REGISTRY }}
username: ${{ matrix.DOCKER_REGISTRY == 'docker.io' && secrets.DOCKERHUB_USERNAME || github.actor }}
password: ${{ matrix.DOCKER_REGISTRY == 'docker.io' && secrets.DOCKERHUB_TOKEN || secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository_owner }}/fabric-nodeenv
images: ${{ matrix.DOCKER_REGISTRY }}/${{ github.repository_owner }}/fabric-nodeenv
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}

- name: Build and push ${{ matrix.COMPONENT }} Image
- name: Build and push image
id: push
uses: docker/build-push-action@v5
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
setup:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
outputs:
PACKAGE_VERSION: ${{ steps.builddata.outputs.PACKAGE_VERSION }}
MINOR_PACKAGE_VERSION: ${{ steps.builddata.outputs.MINOR_PACKAGE_VERSION }}
Expand Down Expand Up @@ -37,12 +37,12 @@ jobs:
echo "BUILD_DATE=${BUILD_DATE}" >> $GITHUB_OUTPUT

build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: "18.x"
- name: Install/Rebuild/UnitTest
run: |
set -xev
Expand Down Expand Up @@ -74,13 +74,13 @@ jobs:
path: fabric-nodeenv.tar.gz

fvtest:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: "18.x"
- uses: actions/download-artifact@v4
with:
name: nodeenv-docker-image
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/vulnerability-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
# Pulling in all the dependencies it will be able to run NPM AUDIT, and if that returns a
# error code the job will fail.
scan:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand Down
Loading
Loading