website/dist/notes/selfhost-forgejo-with-podman-without-quadlet/index.html
2025-06-12 11:59:23 +02:00

36 lines
No EOL
8.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"> <head><meta charset="UTF-8"><meta name="description" content="Evalyte"><meta name="viewport" content="width=device-width"><!--<link rel="icon" type="image/svg+xml" href="/favicon.svg" />--><meta name="generator" content="Astro v5.9.2"><title>undefined - Evalyte</title><script defer src="https://umami.evalyte.net/script.js" data-website-id="4fd77337-0f39-4eac-b19b-c09ebf8c8db3"></script><style>@media (prefers-color-scheme: dark){.markdown-alert{--color-border-default: #30363d;--color-accent-fg: #58a6ff;--color-accent-emphasis: #1f6feb;--color-danger-fg: #f85149;--color-danger-emphasis: #da3633;--color-attention-fg: #d29922;--color-attention-emphasis: #9e6a03;--color-done-fg: #a371f7;--color-done-emphasis: #8957e5;--color-success-fg: #3fb950;--color-success-emphasis: #238636}}@media (prefers-color-scheme: light){.markdown-alert{--color-border-default: #d0d7de;--color-accent-fg: #0969da;--color-accent-emphasis: #0969da;--color-danger-fg: #d1242f;--color-danger-emphasis: #cf222e;--color-attention-fg: #9a6700;--color-attention-emphasis: #9a6700;--color-done-fg: #8250df;--color-done-emphasis: #8250df;--color-success-fg: #1a7f37;--color-success-emphasis: #1f883d}}.markdown-alert{border-left:.25em solid var(--borderColor-default, var(--color-border-default));color:inherit;margin-bottom:16px;padding:.5rem 1em}.markdown-alert>:last-child{margin-bottom:0!important}.markdown-alert .markdown-alert-title{align-items:center;display:flex;font-size:14px;font-weight:500;line-height:1}.markdown-alert .markdown-alert-title svg.octicon{margin-right:8px!important;margin-right:var(--base-size-8,8px)!important;fill:currentColor}.markdown-alert.markdown-alert-note{border-left-color:var(--borderColor-accent-emphasis,var(--color-accent-emphasis))}.markdown-alert.markdown-alert-note .markdown-alert-title{color:var(--color-accent-fg);color:var(--fgColor-accent,var(--color-accent-fg))}.markdown-alert.markdown-alert-tip{border-left-color:var(--borderColor-success-emphasis,var(--color-success-emphasis))}.markdown-alert.markdown-alert-tip .markdown-alert-title{color:var(--color-success-fg);color:var(--fgColor-success,var(--color-success-fg))}.markdown-alert.markdown-alert-important{border-left-color:var(--borderColor-done-emphasis,var(--color-done-emphasis))}.markdown-alert.markdown-alert-important .markdown-alert-title{color:var(--color-done-fg);color:var(--fgColor-done,var(--color-done-fg))}.markdown-alert.markdown-alert-warning{border-left-color:var(--borderColor-attention-emphasis,var(--color-attention-emphasis))}.markdown-alert.markdown-alert-warning .markdown-alert-title{color:var(--color-attention-fg);color:var(--fgColor-attention,var(--color-attention-fg))}.markdown-alert.markdown-alert-caution{border-left-color:var(--borderColor-danger-emphasis,var(--color-danger-emphasis))}.markdown-alert.markdown-alert-caution .markdown-alert-title{color:var(--color-danger-fg);color:var(--fgColor-danger,var(--color-danger-fg))}main[data-astro-cid-hhdr4bp3]{padding:32px;display:flex;flex-direction:column;align-items:center;margin:auto;max-width:1200px;gap:32px}
@font-face{font-family:Comfortaa;src:url(/fonts/Comfortaa-Regular.ttf);font-weight:400}@font-face{font-family:Comfortaa;src:url(/fonts/Comfortaa-Bold.ttf);font-weight:700}:root{--primary: #5d9eda;--secondary: #b1d0ee;--background: #282c34;--pane: #21252b;--surface: #31353f;--surface2: #51555f;--text: #d1d1d1;--headline: #ffffff;--hint: #797979;color:var(--text);--default-gap: 16px}a{text-decoration:none;color:var(--secondary)}nav>a{color:var(--text)}body{margin:0;min-height:100vh;display:flex;flex-direction:column}html{margin:0;font-family:system-ui,sans-serif;background:var(--background)}main{flex:1}header{background:var(--pane)}header>div{display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:2rem;margin:auto;padding:16px;font-family:Comfortaa;font-weight:700;font-size:1rem;@media (min-width: 1200px){width:1200px}}nav{display:flex;flex-direction:row;align-items:center;gap:2rem}#logo{font-size:2rem;color:var(--primary);text-wrap:nowrap}h1,h2,h3,h4{font-family:Comfortaa;font-weight:400;color:var(--headline);padding:0}h1{color:var(--primary);font-size:3rem}h2{font-size:2rem}h3{font-size:1.5rem}h4{font-size:1.25rem}code{font-family:Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace}code:not(pre>code){background-color:#21252b;font-size:.9rem;padding:0 4px;border-radius:4px}.astro-code{padding:16px;max-width:80vw}pre{background-color:#21252b!important}.markdown-alert-title{margin-bottom:8px}footer{color:var(--hint);text-align:center;margin-bottom:16px}
</style></head> <body> <header> <div> <a href="/" id="logo">&gt; _</a> <nav> <a href="https://code.evalyte.net" target="_blank">Repositories</a> <!--<a href="/devlog">Devlog</a>--> <a href="/notes">Notes</a> <!--<a href="/utilities">Utilities</a>--> <!--<a href="/services">Services</a>--> <a href="/about">About</a> </nav> </div> </header> <main data-astro-cid-hhdr4bp3> <div style="display:flex;flex-direction:column;gap:var(--default-gap);justify-content:center;align-items:start"> <div style="display:flex;flex-direction:column;gap:var(--default-gap);justify-content:center;align-items:start"> <h1 data-astro-cid-hhdr4bp3>Selfhost Forgejo with Podman without Quadlet</h1> </div> <div style="flex:1"> <p data-astro-cid-hhdr4bp3> <p>When self-hosting Forgejo, <a href="https://forgejo.org/docs/latest/admin/installation/">the official documentation</a>
provides the steps for binary, Docker and Podman.</p>
<p>However the provided steps for installing with Podman use Quadlet, and if youre out of luck and
Quadlet isnt available in your environment you have to use the Podman CLI, but your lose some nice
things that Quadlet has, especially restart on boot.</p>
<p>Unfortunatly the Forgejo documentation doesnt tell us how to but its easily deductible from the
Quadlet/Systemd config file they provide</p>
<h3 id="script">Script</h3>
<div class="markdown-alert markdown-alert-note" dir="auto">
<p class="markdown-alert-title" dir="auto"><svg class="octicon" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path></svg>NOTE</p>
<p>You might need to modify some values in the script below for your use case</p>
</div>
<p>First, create a directory named <code>forgejo-volume</code>, then create the <code>data</code> and <code>conf</code> directories
inside it so you have <code>forgejo-volume/data</code> and <code>forgejo-volume/conf</code></p>
<p>Then the command is:</p>
<pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-language="bash"><code><span class="line"><span style="color:#B392F0">podman</span><span style="color:#9ECBFF"> run</span><span style="color:#79B8FF"> \</span></span>
<span class="line"><span style="color:#79B8FF"> --name</span><span style="color:#9ECBFF"> forgejo</span><span style="color:#79B8FF"> \</span></span>
<span class="line"><span style="color:#79B8FF"> --restart=always</span><span style="color:#79B8FF"> \</span></span>
<span class="line"><span style="color:#79B8FF"> --userns=keep-id:uid=1000,gid=1000</span><span style="color:#79B8FF"> \</span></span>
<span class="line"><span style="color:#79B8FF"> -p</span><span style="color:#9ECBFF"> 3000:3000</span><span style="color:#79B8FF"> \</span></span>
<span class="line"><span style="color:#79B8FF"> -p</span><span style="color:#9ECBFF"> 2222:2222</span><span style="color:#79B8FF"> \</span></span>
<span class="line"><span style="color:#79B8FF"> -v</span><span style="color:#9ECBFF"> ./forgejo-volume/data:/var/lib/gitea</span><span style="color:#79B8FF"> \</span></span>
<span class="line"><span style="color:#79B8FF"> -v</span><span style="color:#9ECBFF"> ./forgejo-volume/conf:/etc/gitea</span><span style="color:#79B8FF"> \</span></span>
<span class="line"><span style="color:#9ECBFF"> codeberg.org/forgejo/forgejo:11-rootless</span></span></code></pre>
<p>Some explanation:</p>
<ul>
<li><code>--restart=always</code> allows us to restart the container on boot, you need to tell systemd to do it
with <code>systemctl --user enable podman-restart.service</code></li>
<li><code>--userns=keep-id:uid=1000,gid=1000</code> 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)</li>
<li><code>-p 3000:3000</code> Forgejo will listen on port 3000</li>
<li><code>-p 2222:2222</code> Forgejo will accept SSH through port 2222</li>
<li>the two following <code>-v</code> parameters map the volume to the directories inside the container</li>
</ul> </p> </div> </div> </main> <footer>© 2024 Evalyte</footer> </body></html>