(deploy) add Scalingo buildpack + dynamic favicon

This commit is contained in:
Sylvain Zimmer
2026-02-11 09:49:30 +01:00
parent 797d92ff62
commit ef1583b595
9 changed files with 176 additions and 8 deletions

20
bin/export_pg_vars.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
# Parse DATABASE_URL into individual PG* environment variables.
# Usage: source bin/export_pg_vars.sh
#
# Needed because PHP (server.php) and psql (init-database.sh) expect
# PGHOST, PGPORT, PGDATABASE, PGUSER, PGPASSWORD — but Scalingo only
# provides DATABASE_URL.
if [ -n "$DATABASE_URL" ] && [ -z "$PGHOST" ]; then
eval "$(python3 -c "
import os, urllib.parse
u = urllib.parse.urlparse(os.environ['DATABASE_URL'])
print(f'export PGHOST=\"{u.hostname}\"')
print(f'export PGPORT=\"{u.port or 5432}\"')
print(f'export PGDATABASE=\"{u.path.lstrip(\"/\")}\"')
print(f'export PGUSER=\"{u.username}\"')
print(f'export PGPASSWORD=\"{urllib.parse.unquote(u.password)}\"')
")"
echo "-----> Parsed DATABASE_URL into PG* vars (host=$PGHOST port=$PGPORT db=$PGDATABASE)"
fi

View File

@@ -13,3 +13,46 @@ mv src/backend/* ./
mv src/nginx/* ./
echo "3.13" > .python-version
# --- PHP + SabreDAV setup ---
echo "-----> Installing PHP 8.3 from Ubuntu packages"
PHP_PREFIX=".php"
DEB_DIR="/tmp/php-debs"
mkdir -p "$DEB_DIR" "$PHP_PREFIX"
BASE_URL="http://security.ubuntu.com/ubuntu/pool/main/p/php8.3"
VERSION="8.3.6-0ubuntu0.24.04.6"
for pkg in cli fpm common opcache readline pgsql xml mbstring curl; do
echo " Downloading php8.3-${pkg}"
curl -fsSL -o "$DEB_DIR/php8.3-${pkg}.deb" \
"${BASE_URL}/php8.3-${pkg}_${VERSION}_amd64.deb"
done
curl -fsSL -o "$DEB_DIR/php-common.deb" \
"http://mirrors.kernel.org/ubuntu/pool/main/p/php-defaults/php-common_93ubuntu2_all.deb"
for deb in "$DEB_DIR"/*.deb; do
dpkg-deb -x "$deb" "$PHP_PREFIX"
done
# Create php wrapper
cat > bin/php << 'WRAPPER'
#!/bin/bash
DIR="$(cd "$(dirname "$0")/.." && pwd)"
PHP_INI_SCAN_DIR="$DIR/.php/etc/php/8.3/cli/conf.d" \
exec "$DIR/.php/usr/bin/php8.3" "$@"
WRAPPER
chmod +x bin/php
echo "-----> PHP version: $(bin/php -v | head -1)"
# Download Composer and install SabreDAV dependencies
echo "-----> Installing SabreDAV dependencies"
curl -fsSL -o bin/composer.phar \
https://getcomposer.org/download/latest-stable/composer.phar
cp -r docker/sabredav sabredav
cd sabredav
../bin/php ../bin/composer.phar install \
--no-dev --optimize-autoloader --no-interaction
cd ..

View File

@@ -1,5 +1,14 @@
#!/bin/bash
# Parse DATABASE_URL into PG* vars for PHP and psql
source bin/export_pg_vars.sh
# Start PHP-FPM for SabreDAV (CalDAV server)
PHP_INI_SCAN_DIR=/app/.php/etc/php/8.3/cli/conf.d \
.php/usr/sbin/php-fpm8.3 \
--fpm-config /app/sabredav/php-fpm.conf \
--nodaemonize &
# Start the Django backend
gunicorn -b :8000 calendars.wsgi:application --log-file - &