Skip to content

Commit 28af281

Browse files
authored
Add podman quadlet installation method (#602)
Signed-off-by: Lukas Zapletal <[email protected]>
1 parent a5b8d05 commit 28af281

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

docs/community-installation-guide.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,113 @@ loginctl enable-linger
9999
podman auto-update
100100
podman image prune -f
101101
```
102+
103+
## Podman via systemd
104+
105+
This method is suitable for systems which come with Podman version 5.x or higher and systemd (e.g. Fedora, CentOS Stream 9 or clones). Instructions are written for root-less mode, do not run the commands as root since paths are different. Ensure that SELinux is in enforcing mode for maximum security.
106+
107+
Create a new volume for database:
108+
109+
podman volume create invidious-db
110+
111+
Start a temporary container:
112+
113+
podman run --rm -it --name invidious-init -v invidious-db:/var/lib/postgresql/data:Z -p 5432:5432 -e POSTGRES_DB=invidious -e POSTGRES_USER=kemal -e POSTGRES_PASSWORD=kemal docker.io/library/postgres:14
114+
115+
In another terminal, migrate the database:
116+
117+
export PGPASSWORD=kemal
118+
for F in channels videos channel_videos users session_ids nonces annotations playlists playlist_videos; do
119+
curl -s https://raw.githubusercontent.com/iv-org/invidious/refs/heads/master/config/sql/$F.sql | \
120+
psql -h localhost -p 5432 -U kemal invidious
121+
done
122+
123+
Shutdown the temporary container, it is no longer needed. Create a database volume unit:
124+
125+
cat > ~/.config/containers/systemd/invidious-db.volume <<EOF
126+
[Volume]
127+
VolumeName=invidious-db
128+
EOF
129+
130+
And a database container:
131+
132+
cat > ~/.config/containers/systemd/invidious-db.container <<EOF
133+
[Container]
134+
ContainerName=invidious-db
135+
Environment=POSTGRES_DB=invidious POSTGRES_USER=kemal POSTGRES_PASSWORD=kemal
136+
Image=docker.io/library/postgres:14
137+
HealthCmd=pg_isready -h localhost -p 5432 -U kemal -d invidious
138+
Notify=healthy
139+
Pod=invidious.pod
140+
Volume=invidious-db.volume:/var/lib/postgresql/data:Z
141+
EOF
142+
143+
Create a helper container:
144+
145+
cat > ~/.config/containers/systemd/invidious-sig-helper.container <<EOF
146+
[Container]
147+
ContainerName=invidious-sig-helper
148+
Environment=RUST_LOG=info
149+
Image=quay.io/invidious/inv-sig-helper:latest
150+
Exec=--tcp 0.0.0.0:12999
151+
Pod=invidious.pod
152+
EOF
153+
154+
Generate your `VISITOR_DATA` an `PO_TOKEN` secrets. For more information about these, read the information dialog above.
155+
156+
podman run quay.io/invidious/youtube-trusted-session-generator
157+
158+
Set those secrets as temporary environmental variables, also generate a random string for HMAC secret:
159+
160+
HMAC=$(openssl rand -base64 21)
161+
VISITOR_DATA="ABCDEF%3D%3D" # notsecret
162+
PO_TOKEN="MpOIfiljfsdljds-Lljfsdk-ojrdjXVs==" # notsecret
163+
164+
In the same terminal where you defined the environmental variables, create new environmental config file:
165+
166+
cat > ~/.config/containers/systemd/invidious.env <<EOF
167+
INVIDIOUS_DATABASE_URL="postgres://kemal:kemal@invidious-db:5432/invidious"
168+
#INVIDIOUS_CHECK_TABLES=true
169+
#INVIDIOUS_DOMAIN="inv.example.com"
170+
INVIDIOUS_SIGNATURE_SERVER="invidious-sig-helper:12999"
171+
INVIDIOUS_VISITOR_DATA="$VISITOR_DATA"
172+
INVIDIOUS_PO_TOKEN="$PO_TOKEN"
173+
INVIDIOUS_HMAC_KEY="$HMAC"
174+
EOF
175+
176+
From now on, if you need to change configuration just edit the generated file `~/.config/containers/systemd/invidious.env`. Now, create invidious container unit:
177+
178+
cat > ~/.config/containers/systemd/invidious.container <<EOF
179+
[Container]
180+
ContainerName=invidious
181+
EnvironmentFile=%h/.config/containers/systemd/invidious.env
182+
Image=quay.io/invidious/invidious:latest
183+
Pod=invidious.pod
184+
[Unit]
185+
After=invidious-db.service
186+
EOF
187+
188+
And finally, create pod unit. Note only port 3000 is exposed, do not expose other ports!
189+
190+
cat > ~/.config/containers/systemd/invidious.pod <<EOF
191+
[Pod]
192+
PodName=invidious
193+
PublishPort=3000:3000
194+
[Install]
195+
WantedBy=multi-user.target default.target
196+
EOF
197+
198+
Systemd units are generated on-the-fly during `daemon-reload` command, but before that let's check syntax with quadlet generator. Note, you need Podman version 5.0 or higher, older versions will not work:
199+
200+
/usr/libexec/podman/quadlet -dryrun -user
201+
202+
Reload systemd daemon. Keep in mind you need to do this command every time you change a unit file, you can change the environmental file freely tho.
203+
204+
systemctl --user daemon-reload
205+
206+
And the whole application can be now started:
207+
208+
systemctl --user start invidious-pod
209+
210+
Keep in mind that generated units cannot be enabled using `systemctl enable`, the main pod will be enabled automatically. If you do not like this behavior, remove the `WantedBy` line from `invidious.pod`.
211+

0 commit comments

Comments
 (0)