Skip to content

Instantly share code, notes, and snippets.

@thimslugga
Forked from toriato/!README.md
Last active April 5, 2025 02:46
Show Gist options
  • Save thimslugga/d8728dd052f00f68819281bd840ce313 to your computer and use it in GitHub Desktop.
Save thimslugga/d8728dd052f00f68819281bd840ce313 to your computer and use it in GitHub Desktop.
Podman Quadlet Example
FROM php:8.2-fpm-alpine
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN \
chmod +x /usr/local/bin/install-php-extensions \
&& install-php-extensions \
apcu bcmath bz2 ldap pdo_mysql pdo_pgsql exif sysvsem smbclient intl imap pcntl soap imagick gmp gd zip
[Build]
ImageTag=localhost/php-fpm
File=./php-fpm/build/Containerfile
SetWorkingDirectory=unit
[Unit]
Description=A popular general-purpose scripting language that is especially suited to web development
[Service]
Restart=always
TimeoutStartSec=900
[Container]
Image=php-fpm.build
AutoUpdate=local
Exec=php-fpm -R
Network=some.network
PublishPort=127.10.1.1:9000-9100:9000-9100/tcp
Volume=/run/mysqld:/run/mysqld
# relative path is based on ~/.config/containers/systemd
# e.g. ./php-fpm = ~/.config/containers/systemd/php-fpm
Volume=./php-fpm/config/php:/usr/local/etc/php:ro
Volume=./php-fpm/config/php-fpm.d:/usr/local/etc/php-fpm.d:ro
Volume=./php-fpm/config/php-fpm.conf:/usr/local/etc/php-fpm.conf:ro
# nginx
Volume=/var/www:/var/www
[Install]
WantedBy=default.target
#!/bin/sh
# Simple podman exec macro for quadlet containers
# Place this script into ~/.profile
#
# $ crontab -l
# */5 * * * * . ~/.profile && XDG_RUNTIME_DIR="/run/user/$(id -u)" nextcloud_cron
# 0 * * * * . ~/.profile && XDG_RUNTIME_DIR="/run/user/$(id -u)" nextcloud_occ files:scan --path=user/files
function quadlet() {
local container=$1
if [ -z "$container" ]; then
echo 'container name is required'
return 1
fi
shift
if ! podman container exists "systemd-${container}"; then
echo 'unable to exec from invalid container'
return 1
fi
if ! systemctl --user is-active --quiet "$container"; then
echo 'unable to exec from inactive container'
return 1
fi
podman exec "systemd-${container}" "$@"
}
function php() {
quadlet php-fpm php "$@"
}
function nextcloud_occ() {
php /path/to/nextcloud/occ "$@"
}
function nextcloud_cron() {
php /path/to/nextcloud/cron.php "$@"
}
function nextcloud_updater() {
php /path/to/nextcloud/updater/updater.phar "$@"
}
[Network]
Subnet=172.16.0.0/24
Gateway=172.16.0.1
IPRange=172.16.0.0/24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment