redimp / otterwiki

A minimalistic wiki powered by python, markdown and git.
https://otterwiki.com
MIT License
648 stars 29 forks source link

Documentation on using gunicorn and uv run #146

Open simonw opened 1 month ago

simonw commented 1 month ago

The https://otterwiki.com/Installation instructions currently lean towards "production" installations - Docker, Kubernetes, uwsgi.

I wanted to try it out on my laptop with the least possible steps - it turns out this worked for me:

git clone https://github.com/redimp/otterwiki.git
cd otterwiki

mkdir -p app-data/repository
git init app-data/repository

echo "REPOSITORY='${PWD}/app-data/repository'" >> settings.cfg
echo "SQLALCHEMY_DATABASE_URI='sqlite:///${PWD}/app-data/db.sqlite'" >> settings.cfg
echo "SECRET_KEY='$(echo $RANDOM | md5sum | head -c 16)'" >> settings.cfg

export OTTERWIKI_SETTINGS=$PWD/settings.cfg
uv run --with gunicorn gunicorn --bind 127.0.0.1:8080 otterwiki.server:app

This uv run command automatically creates a virtual environment, installs the pyproject.toml dependencies, installs gunicorn as well (--with gunicorn) and starts that running the server.

simonw commented 1 month ago

It would be cool if the otterwiki PyPI package could be run something like this:

pip install otterwiki
otterwiki \
  --repository app-data/repository \
  --db sqlite:///${PWD}/app-data/db.sqlite \
  --secret-key secret1 \
  --port 8080

That would make it even easier for people to try it out.

e12e commented 1 month ago

Nice. I assume your first snippet assumes pip install uv or equivalent?

simonw commented 1 month ago

Yes, install uv using your method of choice: https://docs.astral.sh/uv/getting-started/installation/

redimp commented 1 month ago

Hey @simonw, I like to idea of running An Otter Wiki via a shell command. At least for testing in a non-production environment this would be very useful! With using not just flask but running a wsgi server (for example uv as you suggested) even in production environments.

I'll take a look at how this can be implemented.