-
Notifications
You must be signed in to change notification settings - Fork 2
π³ Multi-stage docker builds, publish pipelines, v2 versioning, CHANGELOG automation
#46
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
Open
lelia
wants to merge
31
commits into
main
Choose a base branch
from
lelia/ghcr-docker-image-build
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
c3ca79c
Multi-stage builds with pinned binary deps, slim base image
lelia 33b6428
Introduce publish-docker workflow and matrix logic
lelia 5300437
Add dependabot config for keeping docker images up to date
lelia 68a5a5d
Add config for autogen release notes
lelia 92cc12e
Update git ignore rules
lelia 440b44d
Add dynamic CI matrix script for new workflow
lelia c163312
Update docker smoketest to reflect new build patterns
lelia 1e7e451
Add integration tests for new docker builds
lelia 240f04f
Add initial CHANGELOG with versioning note, plus script for automatedβ¦
lelia 1b46093
Update docs to cover prebuilt image usage, v2 pinning strategies, relβ¦
lelia 13c4ac9
Update integration test script to use less-heavy scan for CI
lelia ba9f09d
Fix auto-generated matrix job names
lelia 7b346c3
Replace implicit dependency with explicit tag_push: bool input
lelia fec7f69
Track node version with Dependabot for consistency
lelia d90739d
Point usage docs at dockerhub instead of GHCR for stability
lelia f9b9c4b
Bump oss toolchain versions in docs
lelia 669e908
Update dockerfile to use latest oss toolchain versions
lelia 38cb0e0
Remove unused matrix script
lelia b3faedf
Remove matrix logic and flatten GHA workflow jobs
lelia ade72e6
Bump uv version per changelog
lelia b55b0b6
Update action manifest to reference plan for release workflow sequence
lelia f773e7d
Add github PR template for new release workflow checklist
lelia 9217e6e
Remove deprecated version bump script logic
lelia 24fd458
Add assertion test to enforce action.yml update on release
lelia 63dce6c
Add note in PR template about action.yml CI enforcement
lelia 3f27083
Update release workflow docs to cover PR template and CI enforcement
lelia 5d2d32e
Update README to use prebuilt image, move testing docs
lelia 67b7865
Update GHA docs to focus on user guidance, move release process to seβ¦
lelia ba90af0
Remove deprecated precommit hook docs
lelia 8556ccd
Add dedicated doc for new release process + checklist
lelia ebb424c
Add initial PR template to facilitate new release PR workflow + checkβ¦
lelia 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,41 @@ | ||
| # Git | ||
| .git/ | ||
| .gitignore | ||
| .gitmodules | ||
|
|
||
| # CI / GitHub | ||
| .github/ | ||
|
|
||
| # Tests and test apps | ||
| tests/ | ||
| app_tests/ | ||
|
|
||
| # Docs and scripts (not needed in image) | ||
| docs/ | ||
| scripts/ | ||
|
|
||
| # Markdown (keep README.md β it's copied explicitly in the Dockerfile) | ||
| *.md | ||
| !README.md | ||
|
|
||
| # Python build artifacts | ||
| __pycache__/ | ||
| *.pyc | ||
| *.pyo | ||
| *.pyd | ||
| .pytest_cache/ | ||
| *.egg-info/ | ||
| dist/ | ||
| build/ | ||
|
|
||
| # Virtual environments | ||
| .venv/ | ||
| venv/ | ||
|
|
||
| # Local config / secrets | ||
| .env | ||
| .env.* | ||
|
|
||
| # Editor | ||
| .vscode/ | ||
| .idea/ |
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,26 @@ | ||
| ## Summary | ||
|
|
||
| <!-- What does this PR do? Why? --> | ||
|
|
||
| ## Changes | ||
|
|
||
| <!-- Bullet points are fine. Link to relevant issues/tickets if applicable. --> | ||
|
|
||
| ## Testing | ||
|
|
||
| <!-- How was this tested? Local smoke test, CI, manual verification, etc. --> | ||
|
|
||
| --- | ||
|
|
||
| ### Release checklist (skip for non-release PRs) | ||
|
|
||
| <!-- Only fill this out if this PR is cutting a new release (e.g. v2.1.0). --> | ||
|
|
||
| - [ ] `socket_basics/version.py` updated to new version | ||
| - [ ] `pyproject.toml` `version:` field updated to match | ||
| - [ ] `action.yml` `image:` ref updated to `docker://ghcr.io/socketdev/socket-basics:<new-version>` *(CI will fail if this doesn't match `pyproject.toml`)* | ||
| - [ ] `CHANGELOG.md` `[Unreleased]` section reviewed *(note: this content is replaced by auto-generated release notes when the tag fires β see [docs/releasing.md](../docs/releasing.md#changelog-and-release-notes))* | ||
|
|
||
| > β οΈ **After merging:** run `publish-docker.yml` via `workflow_dispatch` with the new version | ||
| > **before** creating the git tag. The image must exist in GHCR before the tag is pushed. | ||
| > See [docs/releasing.md](../docs/releasing.md) for the full process. |
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,32 @@ | ||
| version: 2 | ||
| updates: | ||
|
|
||
| # Main Dockerfile β tracks aquasec/trivy, trufflesecurity/trufflehog, | ||
| # ghcr.io/astral-sh/uv, and python base image. | ||
| # NOTE: OPENGREP_VERSION is not trackable via Dependabot (no Docker image); | ||
| # update it manually in the Dockerfile ARG. | ||
| - package-ecosystem: "docker" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| labels: | ||
| - "dependencies" | ||
| - "docker" | ||
|
|
||
| # app_tests Dockerfile β same as above, plus golang and securego/gosec. | ||
| - package-ecosystem: "docker" | ||
| directory: "/app_tests" | ||
| schedule: | ||
| interval: "weekly" | ||
| labels: | ||
| - "dependencies" | ||
| - "docker" | ||
|
|
||
| # GitHub Actions β tracks all uses: ... action versions. | ||
| - package-ecosystem: "github-actions" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| labels: | ||
| - "dependencies" | ||
| - "github-actions" |
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,34 @@ | ||
| # Configures GitHub's auto-generated release notes categories. | ||
| # Used by `gh release create --generate-notes` in publish-docker.yml, | ||
| # and visible in the GitHub "Generate release notes" UI when drafting releases. | ||
| # https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes | ||
|
|
||
| changelog: | ||
| categories: | ||
| - title: "π New Features" | ||
| labels: | ||
| - enhancement | ||
| - feature | ||
| - title: "π Bug Fixes" | ||
| labels: | ||
| - bug | ||
| - fix | ||
| - title: "π Security" | ||
| labels: | ||
| - security | ||
| - title: "π¦ Dependencies" | ||
| labels: | ||
| - dependencies | ||
| - docker | ||
| - title: "βοΈ CI / Build" | ||
| labels: | ||
| - ci | ||
| - github-actions | ||
| - build | ||
| - title: "π Documentation" | ||
| labels: | ||
| - documentation | ||
| - docs | ||
| - title: "π§ Other Changes" | ||
| labels: | ||
| - "*" |
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,172 @@ | ||
| name: _docker-pipeline (reusable) | ||
|
|
||
| # Reusable workflow β the single lego brick for all Docker CI steps. | ||
| # | ||
| # Called by smoke-test.yml (push: false) and publish-docker.yml (push: true). | ||
| # Step visibility is controlled by the push/tag_push inputs; the caller sets permissions. | ||
| # | ||
| # Two modes: | ||
| # push: false β build + smoke test + integration test (main image only) | ||
| # push: true β above + push to GHCR/Docker Hub + update floating v-tag | ||
| # | ||
| # Permissions required from the calling workflow: | ||
| # push: false β contents: read | ||
| # push: true β contents: write, packages: write | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| name: | ||
| description: "Image name, e.g. socket-basics" | ||
| type: string | ||
| required: true | ||
| dockerfile: | ||
| description: "Path to Dockerfile relative to repo root" | ||
| type: string | ||
| required: true | ||
| context: | ||
| description: "Docker build context" | ||
| type: string | ||
| required: false | ||
| default: "." | ||
| check_set: | ||
| description: "Smoke-test tool set: main or app-tests" | ||
| type: string | ||
| required: true | ||
| push: | ||
| description: "Push to GHCR and Docker Hub after testing" | ||
| type: boolean | ||
| required: false | ||
| default: false | ||
| tag_push: | ||
| description: > | ||
| True when the caller was triggered by a tag push (e.g. v2.0.0). | ||
| Controls the floating major-version tag update and the 'latest' Docker tag. | ||
| Passed explicitly rather than relying on github.ref_type inside the callee, | ||
| since context propagation in reusable workflows can be ambiguous. | ||
| type: boolean | ||
| required: false | ||
| default: false | ||
| version: | ||
| description: "Semver without v prefix (e.g. 2.0.0) β used for OCI labels and push tags" | ||
| type: string | ||
| required: false | ||
| default: "dev" | ||
| secrets: | ||
| DOCKERHUB_USERNAME: | ||
| required: false | ||
| DOCKERHUB_TOKEN: | ||
| required: false | ||
|
|
||
| jobs: | ||
| pipeline: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 60 | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: π¨ Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 | ||
|
|
||
| # Logins and metadata are only needed in push mode | ||
| - name: Login to GHCR | ||
| if: inputs.push | ||
| uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ github.token }} | ||
|
|
||
| - name: Login to Docker Hub | ||
| if: inputs.push | ||
| uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
|
||
| - name: Extract image metadata | ||
| if: inputs.push | ||
| id: meta | ||
| uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 | ||
| with: | ||
| images: | | ||
| ghcr.io/socketdev/${{ inputs.name }} | ||
| ${{ secrets.DOCKERHUB_USERNAME }}/${{ inputs.name }} | ||
| tags: | | ||
| # Tag push (v2.0.0) β Docker tags 2.0.0, 2.0, latest | ||
| type=semver,pattern={{version}} | ||
| type=semver,pattern={{major}}.{{minor}} | ||
| type=raw,value=latest,enable=${{ inputs.tag_push }} | ||
| # workflow_dispatch re-publish β use the version input directly | ||
| type=raw,value=${{ inputs.version }},enable=${{ !inputs.tag_push }} | ||
| labels: | | ||
| org.opencontainers.image.title=${{ inputs.name }} | ||
| org.opencontainers.image.source=https://github.com/SocketDev/socket-basics | ||
|
|
||
| # ββ Step 1: Build ββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
| # Loads image into the local Docker daemon without pushing. | ||
| # Writes all layers to the GHA cache so the push step is just an upload. | ||
| - name: π¨ Build (load for testing) | ||
| uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2 | ||
| with: | ||
| context: ${{ inputs.context }} | ||
| file: ${{ inputs.dockerfile }} | ||
| load: true | ||
| push: false | ||
| tags: ${{ inputs.name }}:pipeline-test | ||
| build-args: | | ||
| SOCKET_BASICS_VERSION=${{ inputs.version }} | ||
| VCS_REF=${{ github.sha }} | ||
| BUILD_DATE=${{ github.event.repository.updated_at }} | ||
| cache-from: type=gha,scope=${{ inputs.name }} | ||
| cache-to: type=gha,mode=max,scope=${{ inputs.name }} | ||
|
|
||
| # ββ Step 2: Smoke test βββββββββββββββββββββββββββββββββββββββββββββββββ | ||
| - name: π§ͺ Smoke test | ||
| run: | | ||
| bash ./scripts/smoke-test-docker.sh \ | ||
| --skip-build \ | ||
| --image-tag ${{ inputs.name }}:pipeline-test \ | ||
| --check-set ${{ inputs.check_set }} | ||
|
|
||
| # ββ Step 3: Integration test (main image only) βββββββββββββββββββββββββ | ||
| - name: π¬ Integration test | ||
| if: inputs.name == 'socket-basics' | ||
| run: | | ||
| bash ./scripts/integration-test-docker.sh \ | ||
| --image-tag ${{ inputs.name }}:pipeline-test | ||
|
|
||
| # ββ Step 4: Push to registries (publish mode only) βββββββββββββββββββββ | ||
| # All layers are in the GHA cache from step 1 β this is just an upload. | ||
| - name: π Push to registries | ||
| if: inputs.push | ||
| uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2 | ||
| with: | ||
| context: ${{ inputs.context }} | ||
| file: ${{ inputs.dockerfile }} | ||
| load: false | ||
| push: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| build-args: | | ||
| SOCKET_BASICS_VERSION=${{ inputs.version }} | ||
| VCS_REF=${{ github.sha }} | ||
| BUILD_DATE=${{ github.event.repository.updated_at }} | ||
| cache-from: type=gha,scope=${{ inputs.name }} | ||
| provenance: true | ||
| sbom: true | ||
|
|
||
| # ββ Step 5: Update floating major version tag ββββββββββββββββββββββββββ | ||
| # e.g. after publishing v2.0.1, force-updates the v2 tag to point here. | ||
| # Only runs for the main image on tag pushes (not workflow_dispatch re-publishes). | ||
| - name: π·οΈ Update floating major version tag | ||
| if: inputs.push && inputs.tag_push && inputs.name == 'socket-basics' | ||
| run: | | ||
| MAJOR="${{ github.ref_name }}" | ||
| MAJOR="${MAJOR%%.*}" | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git tag -fa "$MAJOR" -m "Update $MAJOR to ${{ github.ref_name }}" | ||
| git push origin "$MAJOR" --force | ||
Oops, something went wrong.
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.