Skip to content

Build Fixes & Optimisations #16

Merged
aryanmehrotra merged 14 commits intozopdev:mainfrom
akshat-kumar-singhal:main
Feb 25, 2026
Merged

Build Fixes & Optimisations #16
aryanmehrotra merged 14 commits intozopdev:mainfrom
akshat-kumar-singhal:main

Conversation

@akshat-kumar-singhal
Copy link
Contributor

@akshat-kumar-singhal akshat-kumar-singhal commented Feb 18, 2026

  • Update gofr version to resolve error log http: superfluous response.WriteHeader call from gofr.dev/pkg/gofr/http/middleware.(*StatusResponseWriter).WriteHeader (logger.go:23)
  • Updated workflow with latest versions of actions
  • Updated workflow to take target & credentials for image push from github vars so that it doesn't fail in the forked repos as well as keep the username private
  • Changed to distroless image to reduce image size
  • Removed the latest tag

Need to set the below in Github Vars:

  • DOCKER_USERNAME
  • DOCKER_REGISTRY_TARGET

akshat-kumar-singhal and others added 10 commits February 18, 2026 14:30
- Bump Go version to 1.26 in workflow and Dockerfile
- Update golangci-lint to v2.10.1 and migrate config to v2 format
- Update docker/login-action to v3
- Make Docker push configurable via DOCKER_USERNAME, DOCKER_PASSWORD,
  and DOCKER_REGISTRY_TARGET variables
- Add validation step to fail fast if Docker config is missing
- Push both version tag and latest tag on release
- Fix errcheck issues in tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add sanitizePath function to validate paths stay within static directory
- Extract resolveFilePath function to reduce cyclomatic complexity
- Prevents directory traversal attacks via malicious URL paths

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- TestSanitizePath: verifies path normalization behavior
- TestSanitizePathPreventsEscape: verifies all paths stay within static dir

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- G703 (path traversal) in main.go: paths are sanitized via sanitizePath
- G704 (SSRF) in tests: test code intentionally makes HTTP requests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Go's net/http server already handles path traversal by returning
307 redirects for paths containing '..', normalizing them before
they reach the handler. The original code using filepath.Join was
already safe.

Keeping gosec exclusions in .golangci.yml for the false positives.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Instead of failing the workflow when Docker credentials are not
configured, emit warnings and skip the Docker login/push steps.
This allows the release job to complete successfully even without
Docker Hub configuration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Go module caching via actions/setup-go cache: true
- Replace container-based golangci-lint with golangci-lint-action@v6
  (eliminates container pull, adds lint caching)
- Add Docker layer caching via buildx and GitHub Actions cache
- Skip all release steps if Docker config is missing (not just push)
- Remove redundant go mod download steps

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- New check_docker_config job outputs whether Docker is configured
- release_package job skipped cleanly if config missing (via job-level if)
- Cleaner workflow visualization - job shows as "skipped" instead of
  running with all steps skipped

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use gcr.io/distroless/static-debian12 for minimal attack surface
- Build with CGO_ENABLED=0 for static binary
- Add -s -w ldflags to strip debug info and reduce size
- Remove Alpine and apk dependencies

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@akshat-kumar-singhal akshat-kumar-singhal changed the title Build Fixes Build Fixes & Optimisations Feb 18, 2026
@akshat-kumar-singhal
Copy link
Contributor Author

@aryanmehrotra I've updated the workflow to remove the latest tag as per discussion with @vikash
README.md has been updated with tag v0.0.6

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 pull request aims to update dependencies, modernize the build pipeline, and optimize the Docker image. The changes include upgrading the gofr.dev framework version, updating GitHub Actions workflows, switching to a distroless Docker base image, and modernizing the golangci-lint configuration.

Changes:

  • Updated gofr.dev from v1.34.0 to v1.54.3 to resolve HTTP response writer warnings
  • Modernized GitHub Actions workflow with improved version management, Docker configuration validation, and build caching
  • Switched to distroless base image for reduced image size and improved security with nonroot user

Reviewed changes

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

Show a summary per file
File Description
main_test.go Improved error handling by explicitly handling Close() and RemoveAll() return values
go.mod Updated Go version and gofr.dev dependency with numerous transitive dependency updates
go.sum Checksums for updated dependencies
Dockerfile Switched to distroless image, optimized build process with layer caching, added nonroot user for security
README.md Updated Docker image tag reference from latest to v0.0.6
.golangci.yml Modernized configuration to version 2 format with restructured linter settings
.github/workflows/go.yaml Enhanced workflow with Docker config validation, updated action versions, improved caching

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aryanmehrotra aryanmehrotra merged commit 3d03efe into zopdev:main Feb 25, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants