Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.git
.github
.env
data
*.tar.gz
__pycache__
.pytest_cache
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Validate installer and Docker image

on:
push:
branches: [main, "feature/**"]
pull_request:

jobs:
checks:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Shell smoke tests
run: bash tests/smoke.sh
- name: Validate Compose
run: |
bash install.sh docker init
docker compose --env-file .env config --quiet
- name: Build Docker image and validate installed dependencies
run: |
docker compose --env-file .env build efb
docker compose --env-file .env run --rm --no-deps efb python -m pip check
docker compose --env-file .env run --rm --no-deps efb python -c 'import ehforwarderbot.__main__, ehforwarderbot.wizard, efb_telegram_master, efb_wechat_slave; from telegram.ext import JobQueue; JobQueue()'
docker compose --env-file .env run --rm --no-deps efb python -c 'import os,pwd; assert pwd.getpwuid(os.getuid()).pw_dir == os.environ["HOME"]'
mkdir -p data/profiles/default
printf 'master_channel: blueset.telegram\nslave_channels: [blueset.wechat]\nmiddlewares: []\n' > data/profiles/default/config.yaml
docker compose --env-file .env run --rm --no-deps efb python /usr/local/lib/efb-install/validate_profile.py --profile default
printf 'master_channel: blueset.telegram\nslave_channels: [blueset.wechat]\nmiddlewares: [missing.example_plugin]\n' > data/profiles/default/config.yaml
if docker compose --env-file .env run --rm --no-deps efb python /usr/local/lib/efb-install/validate_profile.py --profile default; then
echo "Missing middleware was not detected" >&2
exit 1
fi
docker compose --env-file .env run --rm --no-deps efb ehforwarderbot --help > /dev/null
docker compose --env-file .env run --rm --no-deps efb efb-wizard --help > /dev/null
- name: Verify optional production middlewares in isolated container
run: |
printf 'master_channel: blueset.telegram\nslave_channels: [blueset.wechat]\nmiddlewares: [catbaron.link_preview, catbaron.mp_instantview]\n' > data/profiles/default/config.yaml
docker compose --env-file .env run --rm --no-deps efb sh -ec '
python -m pip install --user "efb-link-preview-middleware==0.1.0" "efb-mp-instantview-middleware==0.3.2"
python -m pip check
python /usr/local/lib/efb-install/validate_profile.py --profile default
'
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.env
/data/
/*.tar.gz
/.pytest_cache/
__pycache__/
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# The legacy Telegram/WeChat plugins may not work on the newest Python.
# Python 3.12 retains imghdr (removed in Python 3.13).
ARG PYTHON_IMAGE=python:3.12-slim-bookworm
FROM ${PYTHON_IMAGE}

ARG EFB_UID=1000
ARG EFB_GID=1000

ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
HOME=/home/efb

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates ffmpeg libmagic1 libcairo2 gcc \
&& rm -rf /var/lib/apt/lists/*

COPY requirements.txt requirements-extra.txt /tmp/
RUN python -m pip install --no-cache-dir -r /tmp/requirements.txt -r /tmp/requirements-extra.txt \
&& rm /tmp/requirements.txt /tmp/requirements-extra.txt
COPY tools/validate_profile.py /usr/local/lib/efb-install/validate_profile.py

RUN if ! getent group "${EFB_GID}" >/dev/null; then groupadd --gid "${EFB_GID}" efb; fi \
&& useradd --uid "${EFB_UID}" --gid "${EFB_GID}" --create-home --home-dir /home/efb --shell /usr/sbin/nologin efb \
&& mkdir -p /home/efb/.ehforwarderbot \
&& chown -R efb:"${EFB_GID}" /home/efb

USER efb
WORKDIR /home/efb
CMD ["ehforwarderbot"]
37 changes: 37 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
services:
efb:
build:
context: .
dockerfile: Dockerfile
args:
EFB_UID: "${EFB_UID:-1000}"
EFB_GID: "${EFB_GID:-1000}"
image: efb-install:local
restart: unless-stopped
init: true
stop_grace_period: 90s
user: "${EFB_UID:-1000}:${EFB_GID:-1000}"
command: ["ehforwarderbot", "--profile", "${EFB_PROFILE:-default}"]
ulimits:
nofile:
soft: 65536
hard: 65536
logging:
driver: json-file
options:
max-size: "10m"
max-file: "5"
environment:
HOME: /home/efb
USER: efb
LOGNAME: efb
XDG_CACHE_HOME: /home/efb/.ehforwarderbot/.cache
PYTHONUNBUFFERED: "1"
TZ: "${TZ:-UTC}"
volumes:
- "${EFB_CONFIG_DIR:-./data}:/home/efb/.ehforwarderbot"
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
# EFB uses outgoing connections; do not expose any inbound ports by default.
Loading