Skip to content

Conversation

@dguido
Copy link
Member

@dguido dguido commented Sep 6, 2025

Summary

  • Fix hadolint and shellcheck issues in Dockerfile
  • Add .dockerignore to optimize build context
  • Improve build reliability and follow Docker best practices

Changes

Dockerfile Improvements

  1. Added SHELL directive with pipefail (fixes DL4006)

    • Added to all 5 build stages (medusa, echidna, toolbox-base, toolbox, toolbox-ci)
    • Ensures piped commands fail properly if any command in the pipeline fails
    • Prevents silent build failures
  2. Use WORKDIR instead of cd (fixes DL3003)

    • Changed medusa build to use WORKDIR /src/medusa instead of cd medusa
    • More idiomatic Docker practice
  3. Fix variable declaration (fixes SC2155)

    • Separate variable assignment from export to avoid masking command failures
    • Now if git describe fails, we can catch the error
  4. Replace echo with printf (fixes SC2028)

    • Ensures consistent escape sequence handling across different systems
    • More portable and reliable for newline characters

Build Optimization

  • Added .dockerignore file to exclude unnecessary files from build context
  • Reduces data sent to Docker daemon, speeding up builds
  • Excludes: .git, .github, documentation, and temporary files

Testing

  • ✅ All Docker stages build successfully
  • ✅ Hadolint warnings resolved (except intentional version pinning)
  • ✅ Build context properly reduced with .dockerignore

Hadolint Results

Before: 11 warnings, 4 info messages
After: 5 warnings (all version pinning - intentionally not fixed), 3 info messages

These changes improve build reliability without affecting functionality.

🤖 Generated with Claude Code
https://claude.ai/code

dguido and others added 3 commits September 6, 2025 11:07
- Add SHELL directive with pipefail option to all build stages (DL4006)
  This ensures that piped commands fail properly if any command in the
  pipeline fails, preventing silent build failures

- Use WORKDIR instead of cd for medusa build (DL3003)
  More idiomatic Docker practice that makes the build context clearer
  and follows Docker best practices

These changes improve build reliability and follow Docker best practices
without affecting the final image functionality.

🤖 Generated with Claude Code
https://claude.ai/code

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix SC2155: Separate variable assignment from export to avoid masking
  command failures. Now if git describe fails, we can catch the error.

- Fix SC2028: Replace echo with printf for consistent escape sequence
  handling across different systems. This ensures newlines are properly
  interpreted regardless of the shell implementation.

These changes improve shell script reliability and portability within
the Docker build process.

🤖 Generated with Claude Code
https://claude.ai/code

Co-Authored-By: Claude <noreply@anthropic.com>
Exclude unnecessary files from the Docker build context to improve
build performance. This reduces the amount of data sent to the Docker
daemon, speeding up builds.

Excluded:
- Git repository data (.git, .gitignore)
- GitHub configuration (.github)
- Documentation files (*.md, LICENSE, CODEOWNERS)
- Build artifacts and temporary files

🤖 Generated with Claude Code
https://claude.ai/code

Co-Authored-By: Claude <noreply@anthropic.com>
@dguido dguido requested a review from elopez as a code owner September 6, 2025 15:29
Resolved conflict by:
- Keeping Go 1.25 from master (latest version)
- Keeping SHELL directive from our branch (hadolint fix)

This combines the latest Go version update with our Dockerfile improvements.
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.

2 participants