From 486990c5edb18c0929e45ad230888894fcfa57d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Engl=C3=B6f=20Ytterstr=C3=B6m?= Date: Tue, 3 Sep 2024 09:12:04 +0200 Subject: [PATCH] Restore waitress defaults --- Containerfile | 2 +- Containerfile.aio | 2 +- README.md | 45 ++++++++++++++++++++++++++++++++++----------- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/Containerfile b/Containerfile index dd5b416..90208c3 100644 --- a/Containerfile +++ b/Containerfile @@ -12,5 +12,5 @@ COPY wsgi.py wsgi.py VOLUME images -ENTRYPOINT waitress-serve --host 127.0.0.1 --port 5099 wsgi:app +ENTRYPOINT waitress-serve wsgi:app diff --git a/Containerfile.aio b/Containerfile.aio index a2f3f36..8bd95b2 100644 --- a/Containerfile.aio +++ b/Containerfile.aio @@ -14,5 +14,5 @@ FROM app AS imgs ARG images copy ${images} images -ENTRYPOINT waitress-serve --host 127.0.0.1 --port 5099 wsgi:app +ENTRYPOINT waitress-serve wsgi:app diff --git a/README.md b/README.md index e6c57ec..38157a2 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,16 @@ There is also a bookmarklet service which enhances sites with many images. Inspirations: -* https://web.archive.org/web/20110504042732/http://placekitten.com/ -* https://web.archive.org/web/20120223050454/http://www.heyben.com/horse_ebookmarklet/. +- https://web.archive.org/web/20110504042732/http://placekitten.com/ +- https://web.archive.org/web/20120223050454/http://www.heyben.com/horse_ebookmarklet/. + +## Example calls + + # generates an image, 200px wide and 300px tall + http://localhost:8080/200/300* + + # generates an image in grayscale, 200px wide and 300px tall + http://localhost:8080/g/200/300 ## Installation @@ -24,8 +32,8 @@ First, create an image collection. 1. Go to the code: `cd path/to/holder`. Copy `images` folder to it. 1. Create and activate a virtualenv. 1. Get dependencies in place: `pip install -r requirements.txt` -1. Start the app: `waitress-serve --host 127.0.0.1 --port 5099 wsgi:app` -1. Go to [http://localhost:5099](http://localhost:5099) in your web browser. +1. Start the app: `waitress-serve wsgi:app` +1. Go to [http://localhost:8080](http://localhost:8080) in your web browser. 1. Done! ### Run as Container @@ -35,18 +43,33 @@ In this build, waitress is used for production readyness. Port 5099 is instead used. podman build . - podman run -it -p 5099:5099 -v ./images:/app/images + podman run -it -p 8080:8080 -v ./images:/app/images If you wish to embed images in container as well, use alternate Containerfile. podman build -f Containerfile.aio --build-arg images=./images . - podman run -it -p 5099:5099 + podman run -it -p 8080:8080 -## Example calls +### Run behind reverse proxy - # generates an image, 200px wide and 300px tall - http://localhost:5000/200/300* +A reverse proxy in front of placeany is recommended. An example +Caddyfile is available to make https "just work", but Nginx+certbot +will be equally fine. - # generates an image in grayscale, 200px wide and 300px tall - http://localhost:5000/g/200/300 +## Podman tip: generate systemd files + +Make sure to enable lingering user processes. + + loginctl enable-linger $USER + +Then, create and change directory to systemd. + + mkdir -p .config/systemd/user + cd .config/systemd/user + +Now, generate the systemd user service. + + podman generate systemd --new -f -n placeany + +Your container can now be enabled and started.