-
Notifications
You must be signed in to change notification settings - Fork 12
feat(packaging): add RPM and DEB package support via nFPM #520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add Linux package generation to the release process using goreleaser's nFPM integration. Packages include: - Systemd service with security hardening (CapabilityBoundingSet, ProtectSystem, NoNewPrivileges, etc.) - Environment file configuration (/etc/default/confd for Debian, /etc/sysconfig/confd for RHEL) - Default confd.toml with documented options - Post-install script with setup instructions - Pre-remove script for clean service shutdown Package architectures: amd64, arm64, armv7 Package formats: .deb (Debian/Ubuntu), .rpm (RHEL/Fedora/CentOS) Packages will be automatically attached to GitHub Releases.
There was a problem hiding this 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 Linux package distribution support for confd by integrating goreleaser's nFPM tool to generate RPM and DEB packages. The packages include a systemd service with comprehensive security hardening features and follow standard Linux filesystem conventions for configuration and state management.
Changes:
- Added nFPM configuration to
.goreleaser.ymlfor automated RPM and DEB package generation - Created systemd service unit with security hardening (capability restrictions, filesystem protection, syscall filtering)
- Added lifecycle scripts (postinstall/preremove) for proper service management and user guidance
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
.goreleaser.yml |
Defines package structure, file locations, dependencies, and build configuration for RPM/DEB packages |
packaging/confd.service |
Systemd unit file with security hardening directives and service lifecycle management |
packaging/confd.default |
Environment file template for configuring backend and runtime options |
packaging/confd.toml.default |
Default configuration file with commented examples of all available settings |
packaging/scripts/postinstall.sh |
Post-installation script that creates directories and displays usage instructions |
packaging/scripts/preremove.sh |
Pre-removal script that stops and disables the service before package removal |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| MemoryDenyWriteExecute=true | ||
|
|
||
| # Allow writes to config directories and common application paths | ||
| ReadWritePaths=/etc /var/lib/confd /var/run |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Granting write access to the entire /etc directory is overly permissive and undermines the ProtectSystem=strict hardening. This allows confd to modify any system configuration file. Consider restricting this to only the specific paths confd needs to write to, such as /etc/confd or specific application configuration directories that confd manages.
| ReadWritePaths=/etc /var/lib/confd /var/run | |
| ReadWritePaths=/etc/confd /var/lib/confd /var/run |
packaging/confd.toml.default
Outdated
| @@ -0,0 +1,68 @@ | |||
| # confd configuration file | |||
| # See https://github.com/abtreece/confd/blob/main/docs/configuration-guide.md | |||
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This documentation link references the 'main' branch which may not correspond to the installed version of confd. Consider using a version-specific documentation link or a stable URL that redirects to the appropriate version's documentation.
| # See https://github.com/abtreece/confd/blob/main/docs/configuration-guide.md | |
| # See the confd configuration guide in the project's documentation (docs/configuration-guide.md). |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #520 +/- ##
==========================================
+ Coverage 62.45% 62.50% +0.05%
==========================================
Files 48 48
Lines 5420 5420
==========================================
+ Hits 3385 3388 +3
+ Misses 1828 1825 -3
Partials 207 207 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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: 45c42cf41d
ℹ️ 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".
packaging/scripts/preremove.sh
Outdated
| # Stop and disable the service before removal | ||
| if command -v systemctl >/dev/null 2>&1; then | ||
| if systemctl is-active --quiet confd 2>/dev/null; then | ||
| echo "Stopping confd service..." | ||
| systemctl stop confd | ||
| fi | ||
| if systemctl is-enabled --quiet confd 2>/dev/null; then | ||
| echo "Disabling confd service..." | ||
| systemctl disable confd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid disabling the service on package upgrades
The preremove script always stops and disables the service. nFPM runs this hook for upgrades as well as removals, so an in-place upgrade will leave confd disabled afterward, and the postinstall hook never re-enables it. This means users who upgrade the package will unexpectedly lose the service until they manually re-enable it. Gate the systemctl disable (and possibly the stop) on a true removal/purge, or check the maintainer-script arguments so upgrades don’t disable the service.
Useful? React with 👍 / 👎.
- Add Linux package installation section to installation.md - Update service-deployment.md with package-based setup instructions - Add comment in confd.service explaining why /etc write access is needed - Improve documentation links in packaging files - Simplify postinstall.sh output with single docs link
- preremove.sh: Only disable service on true removal, not upgrades - DEB receives "remove" or "upgrade" as $1 - RPM receives 0 (uninstall) or 1 (upgrade) as $1 - postinstall.sh: Restart service on upgrade if it was enabled - Only show setup instructions on fresh install - Automatically restart service after upgrade completes This prevents the service from being left disabled after package upgrades.
Summary
/etc/default/confdor/etc/sysconfig/confd)Package Contents
/usr/bin/confd/usr/lib/systemd/system/confd.service/etc/confd/confd.toml/etc/confd/conf.d//etc/confd/templates//etc/default/confd/etc/sysconfig/confd/var/lib/confd/Systemd Security Hardening
The service runs as root but with significant restrictions:
CapabilityBoundingSet- Only essential capabilitiesProtectSystem=strict- Read-only filesystem except allowed pathsNoNewPrivileges=true- Prevent privilege escalationPrivateTmp,PrivateDevices- IsolationSystemCallFilter=@system-service- Restricted syscallsUsage After Install
Test plan
go test ./...passesmake snapshotbuilds packages successfully