-
Notifications
You must be signed in to change notification settings - Fork 1
Add a github action for building image #32
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
Merged
Merged
Changes from all commits
Commits
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 hidden or 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,29 @@ | ||
| name: 🏗️ Build PR | ||
|
|
||
| on: | ||
| pull_request: ~ | ||
|
|
||
| env: | ||
| stream: "pr-${{ github.event.pull_request.number }}" | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build Docker image | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| node: [ '20', '22', '24' ] | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: 🐋 Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: 🏗️ Build Docker image | ||
| uses: docker/bake-action@v6 | ||
| env: | ||
| NODE_VERSION: ${{ matrix.node }} | ||
| STREAM: ${{ env.stream }} |
This file contains hidden or 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,17 @@ | ||
| name: 🏗️ Build and Push Latest | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| workflow_dispatch: ~ | ||
| schedule: | ||
| # At 14:00 UTC every day | ||
| - cron: '0 14 * * *' | ||
|
|
||
| jobs: | ||
| build: | ||
| uses: ./.github/workflows/build-push.yml | ||
| with: | ||
| stream: latest | ||
| push: true | ||
| secrets: inherit |
This file contains hidden or 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,17 @@ | ||
| name: 🏗️ Build and Push Stable | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ releases ] | ||
| workflow_dispatch: ~ | ||
| schedule: | ||
| # At 14:00 UTC every day | ||
| - cron: '0 14 * * *' | ||
|
|
||
| jobs: | ||
| build: | ||
| uses: ./.github/workflows/build-push.yml | ||
| with: | ||
| stream: stable | ||
| push: true | ||
| secrets: inherit |
This file contains hidden or 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,62 @@ | ||
| name: 🏗️ Build and Push | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| runs_on: | ||
| type: string | ||
| default: ubuntu-latest | ||
| description: The image to run the jobs. | ||
| stream: | ||
| type: string | ||
| default: latest | ||
| description: The stream to build (e.g latest or stable). | ||
| push: | ||
| type: boolean | ||
| default: false | ||
| description: Whether to push the built image to the registry. | ||
|
|
||
| secrets: | ||
| DOCKERHUB_USERNAME: | ||
| required: true | ||
| DOCKERHUB_TOKEN: | ||
| required: true | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build Docker image | ||
| runs-on: ${{ inputs.runs_on }} | ||
| permissions: | ||
| packages: write | ||
| contents: read | ||
| attestations: write | ||
| id-token: write | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| node: [ '20', '22', '24' ] | ||
|
|
||
| steps: | ||
| - name: 🔑 Login to Docker Hub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
|
||
| - name: 🔑 Log in to the GitHub Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: 🐋 Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: 🏗️ Build and push Docker image | ||
| uses: docker/bake-action@v6 | ||
| env: | ||
| PHP_VERSION: ${{ matrix.php }} | ||
| STREAM: ${{ inputs.stream }} | ||
| with: | ||
| push: ${{ inputs.push }} |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,34 +1,10 @@ | ||
| #!/usr/bin/make -f | ||
|
|
||
| REGISTRY=skpr/node | ||
| ALPINE_VERSION=3.21 | ||
| NODE_VERSION=20 | ||
| ARCH=amd64 | ||
| VERSION_TAG=v3-latest | ||
| NODE_VERSION=22 | ||
|
|
||
| IMAGE=${REGISTRY}:${NODE_VERSION}-${VERSION_TAG} | ||
| IMAGE_DEV=${REGISTRY}:dev-${NODE_VERSION}-${VERSION_TAG} | ||
|
|
||
| build: | ||
| # Building production image. | ||
| docker build --build-arg FROM_IMAGE=node:${NODE_VERSION}-alpine${ALPINE_VERSION} -t ${IMAGE}-${ARCH} . | ||
| # Building development image. | ||
| docker build --build-arg FROM_IMAGE=${IMAGE}-${ARCH} -t ${IMAGE_DEV}-${ARCH} dev | ||
| # Testing development image. | ||
| container-structure-test test --image ${IMAGE_DEV}-${ARCH} --config tests.yml | ||
|
|
||
| push: | ||
| # Pushing production image. | ||
| docker push ${IMAGE}-${ARCH} | ||
| # Pushing development image. | ||
| docker push ${IMAGE_DEV}-${ARCH} | ||
|
|
||
| manifest: | ||
| # Creating manifest for production image. | ||
| docker manifest create ${IMAGE} --amend ${IMAGE}-arm64 --amend ${IMAGE}-amd64 | ||
| docker manifest push ${IMAGE} | ||
| # Creating manifest for development image. | ||
| docker manifest create ${IMAGE_DEV} --amend ${IMAGE_DEV}-arm64 --amend ${IMAGE_DEV}-amd64 | ||
| docker manifest push ${IMAGE_DEV} | ||
| # Example build command for local development. | ||
| # See Github Action for multi-arch and multi-stream building. | ||
| nbake: | ||
| NODE_VERSION=${NODE_VERSION} docker buildx bake | ||
|
|
||
| .PHONY: * | ||
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.
Uh oh!
There was an error while loading. Please reload this page.