Improve doc

This commit is contained in:
phil 2024-12-01 04:58:49 +01:00
parent 9a2dcd5a77
commit 01ef678823

View file

@ -13,8 +13,8 @@ apt install -y pipx && pipx install uv
Configuration is done by environment variables, prefixed by `SMS_HANDLER_`: Configuration is done by environment variables, prefixed by `SMS_HANDLER_`:
* `SMS_HANDLER_MAIL_SENDER`: origin email address (default: <username>@localhost) * `SMS_HANDLER_MAIL_SENDER`: origin email address (default: *username*@localhost)
* `SMS_HANDLER_MAIL_TO`: destination email address (default: <username>@localhost) * `SMS_HANDLER_MAIL_TO`: destination email address (default: *username*@localhost)
* `SMS_HANDLER_MAIL_SERVER`: address of the mail server (default: localhost) * `SMS_HANDLER_MAIL_SERVER`: address of the mail server (default: localhost)
* `SMS_HANDLER_MAIL_SERVER_PORT`: port of the mail server (default: 25) * `SMS_HANDLER_MAIL_SERVER_PORT`: port of the mail server (default: 25)
* `SMS_HANDLER_MAIL_SERVER_START_TLS`: initiate mail server connection with TLS (default: no) * `SMS_HANDLER_MAIL_SERVER_START_TLS`: initiate mail server connection with TLS (default: no)
@ -34,14 +34,13 @@ The URI path `/sms-handle` is not configurable.
### In foreground ### In foreground
```sh ```sh
fastapi run server:app sms-handler
``` ```
Try `fastapi --help` for configuration of the server: Set port and listen address:
port, address to listen on, etc. For example:
```sh ```sh
fastapi run server:app --port 8025 sms-handler --port 80125 --host 192.168.100.55
``` ```
### As a deamon (Systemd) ### As a deamon (Systemd)
@ -50,26 +49,30 @@ Create a service as follows.
Pass the settings for the web server (listen address, port) in the ExecStart statement, Pass the settings for the web server (listen address, port) in the ExecStart statement,
and the parameters as `Environment=MAIL_SERVER_START_TLS=yes`. and the parameters as `Environment=MAIL_SERVER_START_TLS=yes`.
[Unit] ```systemd
Description=SMS handler [Unit]
Description=SMS handler
[Service]
ExecStart=fastapi run server:app [Service]
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com ExecStart=/home/snoopy/.local/bin/sms-handler
Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
Restart=on-failure Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com
Restart=on-failure
[Install]
WantedBy=default.target [Install]
WantedBy=default.target
```
### Container ### Container
Use `podman` or `docker`: Use `podman` or `docker`:
```sh
podman run tiptop:5000/sms_handler podman run tiptop:5000/sms_handler
``` ```
**Note**: the container is not published publicly yet.
Pass parameters like this: Pass parameters like this:
```sh ```sh
@ -84,19 +87,21 @@ Systemd can "orchestrate" containers easily thanks to podman.
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`:
[Container] ```systemd
ContainerName=sms-handler [Container]
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com ContainerName=sms-handler
Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
Image=tiptop:5000/sms_handler Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com
Network=podman Image=tiptop:5000/sms_handler
PublishPort=80°25:8025 Network=podman
PublishPort=80°25:8025
[Service]
Restart=always [Service]
Restart=always
[Install]
WantedBy=default.target [Install]
WantedBy=default.target
```
Request systemd to reload configuration, creating the service for this container: Request systemd to reload configuration, creating the service for this container:
@ -120,19 +125,21 @@ sudo loginctl enable-linger snoopy
For a rootless container, create a file in `/etc/containers/systemd/sms-handler.container`: For a rootless container, create a file in `/etc/containers/systemd/sms-handler.container`:
[Container] ```systemd
ContainerName=sms-handler [Container]
Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com ContainerName=sms-handler
Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com Environment=SMS_HANDLER_MAIL_SENDER=snoopy@peanuts.com
Image=tiptop:5000/sms_handler Environment=SMS_HANDLER_MAIL_TO=snoopy@peanuts.com
Network=podman Image=tiptop:5000/sms_handler
PublishPort=80°25:8025 Network=podman
PublishPort=80°25:8025
[Service]
Restart=always [Service]
Restart=always
[Install]
WantedBy=default.target [Install]
WantedBy=default.target
```
Request systemd to reload configuration, creating the service for this container: Request systemd to reload configuration, creating the service for this container: