Selfhost Forgejo with Podman without Quadlet
When self-hosting Forgejo, the official documentation provides the steps for binary, Docker and Podman.
However the provided steps for installing with Podman use Quadlet, and if you’re out of luck and Quadlet isn’t available in your environment you have to use the Podman CLI, but your lose some nice things that Quadlet has, especially restart on boot.
Unfortunatly the Forgejo documentation doesn’t tell us how to but it’s easily deductible from the Quadlet/Systemd config file they provide
Script
NOTE
You might need to modify some values in the script below for your use case
First, create a directory named forgejo-volume
, then create the data
and conf
directories
inside it so you have forgejo-volume/data
and forgejo-volume/conf
Then the command is:
podman run \
--name forgejo \
--restart=always \
--userns=keep-id:uid=1000,gid=1000 \
-p 3000:3000 \
-p 2222:2222 \
-v ./forgejo-volume/data:/var/lib/gitea \
-v ./forgejo-volume/conf:/etc/gitea \
codeberg.org/forgejo/forgejo:11-rootless
Some explanation:
--restart=always
allows us to restart the container on boot, you need to tell systemd to do it withsystemctl --user enable podman-restart.service
--userns=keep-id:uid=1000,gid=1000
allows us to keep the permissions for the volume while using 1000 for the UID and GID inside the container (because we are using the rootless version)-p 3000:3000
Forgejo will listen on port 3000-p 2222:2222
Forgejo will accept SSH through port 2222- the two following
-v
parameters map the volume to the directories inside the container