Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 25, 2026

Bundles template files into the Go binary at compile time, eliminating runtime filesystem dependencies.

Changes

  • main.go: Use //go:embed templates/* directive with template.ParseFS() instead of template.ParseFiles()
  • Dockerfile: Remove COPY --from=builder /app/templates /templates line
//go:embed templates/*
var templatesFS embed.FS

// ...
tpl := template.Must(template.ParseFS(templatesFS, "templates/index.html"))
Original prompt

Update this application so that the files it depends on at runtime, specifically the templates and static files, are baked into the binary. The goal here is to make the minimal changes to the Go code so these are bundled and no longer need to be present on the filesystem at runtime.

The current implementation runs as a Docker container and these files are being copied over into the container. The goal is to specifically remove these lines of code from the Dockerfile but otherwise leave the Dockerfile unchanged.

Copy the template folder into the runtime container

COPY --from=builder /app/templates /templates


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: JaredHatfield <208119+JaredHatfield@users.noreply.github.com>
Copilot AI changed the title [WIP] Update application to bundle templates and static files in binary Embed templates into binary using Go embed package Jan 25, 2026
Copilot AI requested a review from JaredHatfield January 25, 2026 01:32
@JaredHatfield JaredHatfield marked this pull request as ready for review January 25, 2026 01:37
@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (7597478) to head (25cb549).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
main.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #111   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files          3       3           
  Lines        118     118           
=====================================
  Misses       118     118           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JaredHatfield JaredHatfield merged commit b4cba13 into main Jan 25, 2026
5 checks passed
@JaredHatfield JaredHatfield deleted the copilot/update-file-bundling-in-binary branch January 25, 2026 01:41
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