Skip to content

Instantly share code, notes, and snippets.

@sjha4
Created August 25, 2026 12:54
Show Gist options
  • Select an option

  • Save sjha4/4b539989d89640109d562e95475173e7 to your computer and use it in GitHub Desktop.

Select an option

Save sjha4/4b539989d89640109d562e95475173e7 to your computer and use it in GitHub Desktop.

Developing smart_proxy_container_gateway in the containerized environment

This documents how to do live development on the smart_proxy_container_gateway plugin against a foremanctl-deployed foreman-proxy container.

How it works

A systemd drop-in config volume-mounts your local git checkout of the plugin's lib/ directory over the RPM-installed gem inside the container. Edits to local files take effect on the next container restart — no image rebuild needed.

Prerequisites

  • A foremanctl deployment with container-gateway enabled
  • A git clone of smart_proxy_container_gateway on the host

Setup (one-time)

1. Clone the plugin

git clone https://github.com/theforeman/smart_proxy_container_gateway.git /root/smart_proxy_container_gateway
cd /root/smart_proxy_container_gateway
git checkout my-feature-branch   # optional: switch to your branch

2. Create the systemd drop-in

The drop-in mounts the local lib/ over the installed gem's lib/ inside the container. Adjust the gem version in the target path if the installed version differs from 4.0.1.

cat > /etc/containers/systemd/foreman-proxy.container.d/dev-container-gateway.conf <<'EOF'
[Container]
Volume=/root/smart_proxy_container_gateway/lib:/usr/share/gems/gems/smart_proxy_container_gateway-4.0.1/lib:Z
EOF

To find the exact installed gem version:

podman exec foreman-proxy gem list smart_proxy_container_gateway

3. Restart foreman-proxy

systemctl daemon-reload
systemctl restart foreman-proxy.service

4. Verify

# Confirm mount is active
podman inspect foreman-proxy --format '{{range .Mounts}}{{.Source}} -> {{.Destination}}{{"\n"}}{{end}}' | grep container_gateway

# Confirm container is running
podman ps --filter name=foreman-proxy

# Check proxy features are loaded
curl -sk https://localhost:9090/features | python3 -m json.tool

Development workflow

edit code locally  →  systemctl restart foreman-proxy  →  test  →  repeat
  1. Edit files under /root/smart_proxy_container_gateway/lib/
  2. Restart the container: systemctl restart foreman-proxy.service
  3. Check logs: podman logs -f foreman-proxy
  4. Test your changes

Switching branches

cd /root/smart_proxy_container_gateway
git checkout other-branch
systemctl restart foreman-proxy.service

No drop-in changes needed — the mount points at the same directory regardless of which branch is checked out.

Tearing down

Remove the drop-in and restart to go back to the RPM-installed gem:

rm /etc/containers/systemd/foreman-proxy.container.d/dev-container-gateway.conf
systemctl daemon-reload
systemctl restart foreman-proxy.service

Notes

  • Only the lib/ directory is mounted. If your changes add new gem dependencies, you need to rebuild the image instead.
  • The :Z suffix on the volume handles SELinux relabeling.
  • The gem version in the target path (4.0.1) must match what's installed in the image. If you update the base image, check and update the drop-in.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment