Installation: Add Release-Via-Docker option

This commit is contained in:
Lain Soykaf 2025-12-31 18:52:14 +04:00
commit db48aa5cdb
7 changed files with 211 additions and 0 deletions

View file

@ -0,0 +1,24 @@
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
gosu \
libstdc++6 \
libncurses6 libncursesw6 \
openssl libssl3 \
libmagic1t64 file \
postgresql-client \
ffmpeg imagemagick libimage-exiftool-perl \
libvips42t64 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt/pleroma
COPY pleroma-host-release-entrypoint.sh /usr/local/bin/pleroma-host-release-entrypoint.sh
RUN chmod +x /usr/local/bin/pleroma-host-release-entrypoint.sh
ENTRYPOINT ["/usr/local/bin/pleroma-host-release-entrypoint.sh"]
CMD ["/opt/pleroma/bin/pleroma", "start"]

View file

@ -0,0 +1,66 @@
# Run OTP releases on older glibc using Docker
Pleroma OTP releases are built on specific distros and may require a newer `glibc`
than your host has. A typical failure looks like:
```
... /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found ...
```
If you don't want to upgrade your host OS, you can run the existing OTP release
from `/opt/pleroma` inside an Ubuntu 24.04 container while keeping your existing
host paths (`/etc/pleroma`, `/var/lib/pleroma`, etc.).
This folder provides a "shim" container + systemd unit. It is **not** the Pleroma
Docker image.
## What this does
- Builds a small Ubuntu 24.04 image with runtime libs (including newer `glibc`).
- Mounts your existing host release at `/opt/pleroma` into the container.
- Runs as the same UID/GID that owns `/opt/pleroma` on the host (via `gosu`).
- Optionally runs migrations automatically on container start.
- Uses `network_mode: host` so your existing config that talks to `localhost`
keeps working.
## Setup (Debian/Ubuntu host)
1. Install Docker Engine + the Docker Compose plugin.
2. Copy these files to a stable location (example: `/etc/pleroma/container`):
```
mkdir -p /etc/pleroma/container
cp -a /opt/pleroma/installation/release-to-docker/* /etc/pleroma/container/
```
3. Build the shim image:
```
cd /etc/pleroma/container
docker compose build
```
4. Replace your systemd unit:
```
cp /etc/pleroma/container/pleroma.service /etc/systemd/system/pleroma.service
systemctl daemon-reload
systemctl enable --now pleroma
journalctl -u pleroma -f
```
## Running `pleroma_ctl`
Since the host binary may not run on older `glibc`, run admin commands inside the
container:
```
cd /etc/pleroma/container
docker compose exec pleroma /opt/pleroma/bin/pleroma_ctl status
docker compose run --rm --no-deps pleroma /opt/pleroma/bin/pleroma_ctl migrate
```
## Configuration notes
- Migrations run automatically by default.
- Set `PLEROMA_RUN_MIGRATIONS=0` in `docker-compose.yml` to disable.

View file

@ -0,0 +1,22 @@
services:
pleroma:
build:
context: .
dockerfile: Dockerfile
image: pleroma-host-release-wrapper:ubuntu24
init: true
network_mode: host
restart: unless-stopped
environment:
HOME: /opt/pleroma
LANG: C.UTF-8
LC_ALL: C.UTF-8
ELIXIR_ERL_OPTIONS: "+fnu"
# Set to 0 to skip running migrations on container start.
PLEROMA_RUN_MIGRATIONS: "1"
volumes:
# Existing OTP release installation (host)
- /opt/pleroma:/opt/pleroma:rw
# Existing config + uploads + static (host)
- /etc/pleroma:/etc/pleroma:rw
- /var/lib/pleroma:/var/lib/pleroma:rw

View file

@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail
uid="${PLEROMA_UID:-}"
gid="${PLEROMA_GID:-}"
if [[ -z "${uid}" || -z "${gid}" ]]; then
uid="$(stat -c '%u' /opt/pleroma)"
gid="$(stat -c '%g' /opt/pleroma)"
fi
export HOME="${HOME:-/opt/pleroma}"
if [[ "${PLEROMA_RUN_MIGRATIONS:-1}" != "0" && "${1:-}" == "/opt/pleroma/bin/pleroma" && "${2:-}" == "start" ]]; then
echo "Running migrations..."
gosu "${uid}:${gid}" /opt/pleroma/bin/pleroma_ctl migrate
fi
exec gosu "${uid}:${gid}" "$@"

View file

@ -0,0 +1,16 @@
[Unit]
Description=Pleroma social network (OTP release via Docker glibc shim)
After=network.target docker.service postgresql.service nginx.service
Requires=docker.service
[Service]
Type=simple
WorkingDirectory=/etc/pleroma/container
ExecStart=/usr/bin/docker compose up --build --remove-orphans
ExecStop=/usr/bin/docker compose down
Restart=on-failure
RestartSec=5s
TimeoutStartSec=0
[Install]
WantedBy=multi-user.target