Skip to content

Add backend Docker build/push workflow and improve Snyk IaC workflow#11

Merged
echska merged 1 commit into
mainfrom
codex/build-docker-image-for-backend-jxkgnq
May 9, 2026
Merged

Add backend Docker build/push workflow and improve Snyk IaC workflow#11
echska merged 1 commit into
mainfrom
codex/build-docker-image-for-backend-jxkgnq

Conversation

@echska
Copy link
Copy Markdown
Owner

@echska echska commented May 9, 2026

Motivation

  • Add automated CI to build and push the backend Docker image to GHCR for changes under parental-control-system/backend.
  • Improve the Infrastructure-as-Code scanning workflow to run Snyk in a container and produce SARIF results for GitHub Code Scanning.
  • Tighten and clarify workflow permissions and use more recent actions to ensure reliable scanning and artifact publishing.

Description

  • Added a new GitHub Actions workflow /.github/workflows/backend-docker.yml that checks out the repo, sets up Docker Buildx, logs into GHCR, extracts metadata with docker/metadata-action@v5, and builds/pushes the image from parental-control-system/backend/Dockerfile using docker/build-push-action@v6 with SHA and latest tags.
  • Updated /.github/workflows/snyk-infrastructure.yml to remove legacy comments, normalize branch syntax, add security-events: write and actions: read permissions, and run the job inside the snyk/snyk:alpine container.
  • Replaced the old Snyk action usage with an explicit run that authenticates via snyk auth "$SNYK_TOKEN" and executes snyk iac test --sarif-file-output=snyk.sarif || true to produce a SARIF file.
  • Switched the SARIF uploader to github/codeql-action/upload-sarif@v4 and made the upload conditional with if: always() && hashFiles('snyk.sarif') != '' to avoid errors when no SARIF is generated.

Testing

  • No automated tests were executed as part of this change; these are CI workflow additions and modifications that will run on the next push to main or on manual dispatch.

Codex Task

@echska echska merged commit 6798250 into main May 9, 2026
0 of 2 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e25726d3e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# or `main.tf` for a Terraform configuration file
file: your-file-to-test.yaml
run: |
snyk auth "$SNYK_TOKEN"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep forked PR scans from failing at auth

Because this workflow still runs on pull_request, forked PRs do not receive SNYK_TOKEN, so this newly unguarded snyk auth "$SNYK_TOKEN" exits before the || true scan/upload path can run. That regresses the previous continue-on-error behavior and makes external PR checks fail rather than just omitting Snyk results; guard this step or skip it when the secret is unavailable.

Useful? React with 👍 / 👎.

Comment on lines 3 to +7
on:
push:
branches: [ "main" ]
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '25 17 * * 1'
branches: [ main ]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore scheduled IaC scans

This on: block now only runs Snyk on pushes and PRs, whereas the previous workflow also had a weekly Monday schedule. That means IaC findings that appear because Snyk's rules change, or because existing configuration becomes newly vulnerable, will not be refreshed in code scanning until someone happens to change the repository; keep the scheduled trigger if continuous infrastructure scanning is still expected.

Useful? React with 👍 / 👎.

images: ${{ env.IMAGE_NAME }}
tags: |
type=sha
type=raw,value=latest
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restrict latest publishes to main

Because this workflow also allows workflow_dispatch, a manual run selected on any non-main ref will still publish the raw latest tag here. That can overwrite the production-looking GHCR tag with unmerged backend code; either gate this tag/push to refs/heads/main or avoid publishing latest for manual non-main runs.

Useful? React with 👍 / 👎.

actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
runs-on: ubuntu-latest
container:
image: snyk/snyk:alpine
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use a glibc-based Snyk job container

Running the whole job in the snyk/snyk:alpine container also moves the JavaScript actions in this job (actions/checkout@v4 and github/codeql-action/upload-sarif@v4) into an Alpine/musl environment. Those actions are executed with the runner's bundled Node binary, which expects glibc, so the workflow can fail before Snyk ever scans; use a glibc-based Snyk image or run only the CLI invocation in the Snyk container.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant