From 087a343ebcf57165f14389a1b15343d026a7e7c3 Mon Sep 17 00:00:00 2001 From: phil Date: Thu, 5 Dec 2024 05:41:57 +0100 Subject: [PATCH] Fix and doc container --- CONTAINER.md | 16 +++++++--------- Containerfile | 6 +++--- README.md | 8 +++++++- pyproject.toml | 2 +- uv.lock | 2 +- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/CONTAINER.md b/CONTAINER.md index 546c8d3..176dbdc 100644 --- a/CONTAINER.md +++ b/CONTAINER.md @@ -3,15 +3,13 @@ Use `podman` or `docker`: ```sh -podman run tiptop:5000/sms_handler +podman run registry.philo.ydns.eu/philo/sms_handler ``` -**Note**: the container is not published publicly yet! - -Pass parameters like this: +Parameters are given as environment variables, eg.: ```sh -podman run -e SMS_HANDLER_MAIL_SERVER_PORT=8025 -e SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com SMS_HANDLER_MAIL_TO=snoopy@peanuts.com tiptop:5000/sms_handler +podman run -e SMS_HANDLER_MAIL_SERVER_PORT=8025 -e SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com SMS_HANDLER_MAIL_TO=snoopy@peanuts.com registry.philo.ydns.eu/philo/sms_handler ``` ## Container as a systemd service @@ -20,14 +18,15 @@ Systemd can "orchestrate" containers easily thanks to podman. ### Rootless (as regular user) -For a rootless container, create a file in `.config/containers/systemd/sms-handler.container`: +For a rootless container, create a file in `.config/containers/systemd/sms-handler.container`. +The configuration is given as environment variables (email addresses `snoopy@peanuts.com` in this example): ```systemd [Container] ContainerName=sms-handler Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com -Image=tiptop:5000/sms_handler +Image=registry.philo.ydns.eu/philo/sms_handler Network=podman PublishPort=8025:8025 @@ -65,7 +64,7 @@ For a rootless container, create a file in `/etc/containers/systemd/sms-handler. ContainerName=sms-handler Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com -Image=tiptop:5000/sms_handler +Image=registry.philo.ydns.eu/philo/sms_handler Network=podman PublishPort=8025:8025 @@ -87,4 +86,3 @@ Start the container as a service: ```sh sudo systemctl start sms-handler.service ``` - diff --git a/Containerfile b/Containerfile index 27b8457..0d48dde 100644 --- a/Containerfile +++ b/Containerfile @@ -1,4 +1,4 @@ -# Build: podman build -t sms-handler -f Containerfile +# Build: podman build -t registry.philo.ydns.eu/philo/sms_handler -f Containerfile FROM docker.io/python:3.12-alpine COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/ @@ -9,6 +9,6 @@ ENV SMS_HANDLER_MAIL_SERVER=host.containers.internal COPY . /src WORKDIR /src -RUN uv sync --frozen --no-cache +RUN uv sync --frozen --no-cache && uv pip install --system . -CMD .venv/bin/fastapi run server.py --port ${PORT} --host ${LISTEN_ADDR} +CMD sms-handler --port ${PORT} --host ${LISTEN_ADDR} diff --git a/README.md b/README.md index fe7fbfb..d9428de 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,13 @@ Restart=on-failure WantedBy=default.target ``` +### Run in a container + +*Sms-handler* is also packaged as a container for running with *docker*, +*podman*, or *Kunernetes*. + +See `CONTAINER.md` for the details. + ## Run behind a reverse proxy *sms-handler* can run behind a reverse proxy (Nginx, Apache, Lighttpd, HAProxy, Caddy, Traefik, etc), @@ -163,4 +170,3 @@ for notification on various devices and automation. *sms-handler* is BSD licensed. Suggestions and contributions are welcome. Donate using Liberapay - diff --git a/pyproject.toml b/pyproject.toml index afcf963..a19d8ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "sms_handler" -version = "0.0.4" +version = "0.0.5" #dynamic = ["version"] description = "Listen to messages from the SMS Forwarder app on Android and send mail" readme = "README.md" diff --git a/uv.lock b/uv.lock index 7a3ebcb..bc5d7cd 100644 --- a/uv.lock +++ b/uv.lock @@ -255,7 +255,7 @@ wheels = [ [[package]] name = "sms-handler" -version = "0.0.1" +version = "0.0.4" source = { editable = "." } dependencies = [ { name = "aiosmtplib" },