Skip to content

Conversation

@kjanat
Copy link
Owner

@kjanat kjanat commented May 28, 2025

Overview

This PR adds comprehensive Docker support and sets up CI workflows for building and pushing Docker images to the GitHub Container Registry (GHCR).

Changes Made

Docker Infrastructure

  • Dockerfile: Multi-stage build using golang:1.23-alpine for builder and scratch for runtime

    • Optimized for small image size
    • Includes build args for version, build time, and git commit injection
    • Non-root user execution for security
  • .dockerignore: Optimizes build context by excluding unnecessary files

  • docker-compose.yml: Local development and testing setup

CI/CD Enhancements

  • Enhanced CI workflow (.github/workflows/ci.yml): Added Docker build and push job
  • Dedicated Docker workflow (.github/workflows/docker.yml): Separate workflow for Docker operations
  • GitHub Container Registry integration: Automatic image publishing with proper tagging strategy
    • Tags: latest and version-based tags
    • Metadata labels for better image management

Application Improvements

  • Enhanced main.go: Added --help flag support displaying:
    • Version information
    • Build timestamp
    • Git commit hash
    • Usage instructions

Documentation

  • Updated README.md: Comprehensive Docker section including:
    • Installation instructions
    • Usage examples
    • Development setup
    • Docker badge and reference links

Docker Usage

Pull and run from GHCR:

docker run --rm -v $(pwd):/data ghcr.io/kjanat/articulate-parser:latest /data/input.txt

Local development:

docker-compose up --build

Testing

  • Docker image builds successfully
  • Application runs correctly in container
  • Help flag displays version information
  • Multi-architecture support ready
  • CI pipeline execution (will be tested after merge)
  • GHCR image push verification (will be verified after merge)

Security Considerations

  • Uses scratch base image for minimal attack surface
  • Runs as non-root user
  • Optimized build context with .dockerignore
  • Proper secret handling in CI workflows

This enhancement makes the articulate-parser easily deployable and integrates seamlessly with containerized workflows.

- Add Dockerfile with multi-stage build using Go 1.23 and scratch base
- Add .dockerignore to optimize build context
- Add docker-compose.yml for local development
- Modify main.go to support --help flag for Docker usage
- Update CI workflow to build and push Docker images to GHCR
- Add dedicated Docker workflow with build tests and multi-platform support
- Update README.md with comprehensive Docker usage examples and badges
- Support for linux/amd64 and linux/arm64 platforms
- Docker images tagged with version, latest, and edge variants
- Includes build-time version injection and metadata labels
@codecov
Copy link

codecov bot commented May 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

kjanat added 3 commits May 28, 2025 14:45
- Added comprehensive description to Docker image labels
- Enhanced CI workflow with more detailed OCI image labels
- Updated Dockerfile with better description matching CI workflow
- Added version, revision, and creation timestamp metadata
- Fix Docker Build Test job by adding load:true to make image available to local daemon
- Enhance Docker metadata and descriptions in docker.yml workflow
- Update README.md with comprehensive Docker documentation
- Add Docker image size badge to README.md
- Add Docker package ecosystem to track base image updates
- Add Docker Compose package ecosystem to track service dependencies
- Maintain same weekly schedule and labeling conventions
@kjanat kjanat self-assigned this May 28, 2025
@kjanat kjanat added documentation Improvements or additions to documentation enhancement New feature or request labels May 28, 2025
@kjanat kjanat requested a review from Copilot May 28, 2025 12:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive Docker support and integrates GitHub Container Registry CI workflows for building, tagging, and pushing Docker images, while also improving application usability through a new help flag.

  • Updates Docker infrastructure with a multi-stage Dockerfile, .dockerignore, and docker-compose configuration.
  • Enhances CI/CD by adding dedicated workflows for Docker testing, build, and push operations.
  • Improves documentation in the README with detailed usage instructions and badge indicators.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
main.go Adds a help flag to display usage and version information.
docker-compose.yml Introduces multiple service definitions for local development and file processing.
README.md Documents Docker image usage, available tags, and usage examples.
Dockerfile Implements a multi-stage build including build metadata injection and a scratch runtime image.
.github/workflows/docker.yml Provides CI workflow for testing, building, and pushing Docker images.
.github/workflows/ci.yml Integrates Docker build & push steps within the CI pipeline.
.github/dependabot.yml Adds update checks for Docker and Docker Compose.
.dockerignore Optimizes the build context by excluding non-essential files.

- Add appuser (UID 1000) in builder stage
- Copy passwd file to scratch image
- Use USER directive to run as non-root user
- Fix docker-compose.yml to use YAML anchors properly
- Add Dockerfile.dev for development with shell access
- Addresses PR review comment about security
kjanat added 2 commits May 28, 2025 15:56
- Add grouping for Docker image updates
- Add grouping for Docker Compose updates
- Group minor and patch updates together
- Update .gitignore to exclude copilot instructions
Add documentation addressing PR feedback:
- Implementation of non-root Docker user
- Explanation of security improvements
- Notes on other PR comments
@kjanat

This comment was marked as outdated.

kjanat and others added 10 commits May 28, 2025 16:48
Merges Docker-related workflows into CI config for unified processing.
Introduces Docker test job to validate image builds in pull requests.
Replaces repetitive YAML configurations with environment variables.
Simplifies test function parameters in Go tests for clarity.

Addresses inefficiencies and reduces workflow duplication.
Simplifies coverage summary generation by removing redundant loop,
and improves Docker build step with the inclusion of SBOM, provenance
attestation, and security scanning features. Updates Docker summary
with new features for enhanced transparency and readiness for
vulnerability analysis.
Introduces concurrency control in CI for efficient workflow execution.
Refines coverage reporting to aggregate by package instead of filename.
Adds Docker documentation outlining usage, available tags, and development
instructions. Updates Dockerfile references to the new documentation.

Improves reliability and clarity of CI and Docker processes.
@kjanat kjanat requested a review from Copilot May 28, 2025 15:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR integrates Docker support and sets up CI workflows to build and publish Docker images to GitHub Container Registry.

  • Introduces multi-stage Dockerfiles and docker-compose.yml for local development.
  • Updates CI (ci.yml) to cache modules, run Docker build/tests, and push images.
  • Expands documentation (README.md, DOCKER.md) with Docker usage, badges, and Dependabot updates.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
main_test.go Renamed test field and added TestRunWithHelpFlags cases
main.go Added help-flag handling in run()
docker-compose.yml Configured services for local and dev scenarios
README.md Added Docker badges and detailed usage sections
Dockerfile.dev New development Dockerfile with shell access
Dockerfile New production multi-stage Dockerfile
DOCKER.md Dedicated Docker documentation
.github/workflows/ci.yml Enhanced CI for Docker build/test and caching
.github/dependabot.yml Added Docker and Docker Compose update checks
.dockerignore Extended ignore patterns for container builds
Comments suppressed due to low confidence (2)

main_test.go:18

  • [nitpick] The field name str is generic; consider reverting to input or a more descriptive name to improve test readability.
str      string

README.md:215

  • [nitpick] The Docker size in README (~15–20MB) conflicts with DOCKER.md (<10MB). Please reconcile the actual image size or remove the approximation.
| **Size**: ~15-20MB compressed

kjanat added 4 commits May 28, 2025 18:34
Updates CI branches and adds support for Go 1.22.x
Integrates CodeQL for security analysis via workflow call
Adds a new workflow for dependency review, enhancing security
Introduces release workflow for automated binary compression and GitHub release creation
Refactors main program to separate usage logic

These changes improve code security and workflow control.

Fixes #123
@kjanat kjanat force-pushed the feature/docker-ghcr branch from 4c7b5f7 to 2b819f6 Compare May 28, 2025 20:43
@kjanat kjanat requested a review from Copilot May 28, 2025 20:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds Docker support and CI workflows for building, testing, and publishing container images to GitHub Container Registry.

  • Introduces multi-stage Dockerfiles (Dockerfile & Dockerfile.dev) and docker-compose.yml for local development and minimal runtime images
  • Enhances CI/CD (.github/workflows/ci.yml) with Docker build/test jobs, retryable dependency downloads, caching, and metadata-driven image publishing
  • Updates main.go and main_test.go to support --help/--version flags, and revises documentation (README.md, DOCKER.md) with Docker usage instructions

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
main.go Added version/help flag handling and extracted usage printing logic
main_test.go Renamed test fields, added tests for help/version flags
Dockerfile & Dockerfile.dev Defined multi-stage builds with non-root user, metadata labels
docker-compose.yml Local development services for parser and shell access
README.md & DOCKER.md Documented Docker image usage, tags, compose, and registry details
.github/workflows/ci.yml Extended CI with Docker build/test jobs, caching, retries, and summary
.github/dependabot.yml Added Docker and Docker Compose update checks
.dockerignore Excluded unnecessary files from Docker build context
Comments suppressed due to low confidence (6)

main_test.go:18

  • [nitpick] The field name str is ambiguous compared to the function parameter input; consider renaming it back to input for clarity and consistency.
str      string

main.go:90

  • Manual string concatenation in a loop can be less efficient; consider using strings.Join(strs, sep) for better performance and readability.
func joinStrings(strs []string, sep string) string {

Dockerfile.dev:46

  • The go build invocation dropped the -ldflags and -o articulate-parser flags, so the binary will be named main without embedded version info; restore those flags and output name.
./main.go

Dockerfile:43

  • Similar to Dockerfile.dev, this build command removed the -ldflags and -o articulate-parser options, resulting in a misnamed binary and missing metadata; reintroduce those flags.
./main.go

main_test.go:246

  • The new tests use os, io, bytes, and strings but these packages aren’t imported at the top; add the missing imports to ensure the tests compile.
oldStdout := os.Stdout

DOCKER.md:25

  • The example omits the required <format> and <output> arguments; update it to ...:latest <source> <format> <output> to match printUsage expectations.
docker run --rm -v $(pwd):/data ghcr.io/kjanat/articulate-parser:latest /data/document.txt

@kjanat
Copy link
Owner Author

kjanat commented May 28, 2025

This pull request introduces significant updates to the CI/CD pipeline, Docker integration, and repository configuration. Key changes include the addition of .dockerignore, new workflows for dependency review and release management, enhancements to the CI pipeline for caching and Docker testing, and the inclusion of a detailed DOCKER.md guide.

CI/CD Pipeline Enhancements:

  • Caching and Dependency Management: Added custom caching for Go modules and implemented retry logic for downloading dependencies in .github/workflows/ci.yml. This improves reliability and reduces build times.
  • Docker Testing: Introduced a docker-test job to validate Docker image builds and test their functionality.
  • Concurrency Control: Enabled concurrency groups to cancel in-progress workflows for the same branch in .github/workflows/ci.yml.

Docker Integration:

  • Docker Build Workflow: Added a docker job to build and push multi-architecture Docker images to GitHub Container Registry, including metadata, SBOM, and provenance attestation.
  • DOCKER.md Documentation: Added a comprehensive guide for using the Docker image, including usage examples, available tags, and development instructions.

Repository Configuration:

  • .dockerignore File: Added .dockerignore to exclude unnecessary files from Docker image builds, reducing image size and build context.
  • Dependabot Updates: Configured Dependabot to monitor Docker and Docker Compose dependencies in .github/dependabot.yml.

New Workflows:

  • Dependency Review Workflow: Added .github/workflows/dependency-review.yml to review dependencies for vulnerabilities, triggered via workflow_call.
  • Release Workflow: Introduced .github/workflows/release.yml to automate release creation, including binary compression and tagging.

@kjanat kjanat merged commit b7f23b2 into master May 28, 2025
13 checks passed
@kjanat kjanat deleted the feature/docker-ghcr branch May 28, 2025 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants