diff --git a/README.md b/README.md index 79c9919..38d65a8 100644 --- a/README.md +++ b/README.md @@ -7,18 +7,31 @@ Graphing polyamorous relationships with force directed layouts. ## Development - -You will need to install Python, virtualenv, and GraphViz using whatever package manager your operating system uses. Then you can setup, run and test the application as follows: +### Run locally +You will need to install Python, virtualenv, libffi (for building cffi) and GraphViz using whatever package manager your operating system uses. Then you can setup, run and test the application as follows: 1. Create a new virtualenv environment by running `make` 2. Run the application by running `make run` and opening http://localhost:5000/ in a browser 3. Run the tests by running `make test` -Alternatively, you can use Docker: - +### Run using Docker 1. Build and run the image by using `docker-compose up --detach` 2. Alternatively, you can use development mode by using `docker-compose -f docker-compose.yml -f docker-compose.dev.yml up` +#### Logging +The Dockerfile (as of writing) uses gunicorn, which doesn' show `print` output. The function below can be used as a replacement +```python +def log(message, path="log.txt"): + with open(path, "a+", encoding="utf-8") as file: + file.write("\n" + message) +``` + +## Environment variables +| Key | Default value | +| ---------- | --------------- | +| ip | `None` | +| DATABASE | `dev.db` | +| SECRET_KEY | `SET ME PLEASE` | ## License This project is licensed under the [MIT License](LICENSE). diff --git a/docker-compose.yml b/docker-compose.yml index 2c88f03..62a401f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,9 @@ -version: "3" services: polycul.es: build: . ports: - 5000:5000 - \ No newline at end of file + environment: + - SECRET_KEY=RAND0M_V@LUE + # - ip=127.0.0.1 + # - DATABASE=dev.db diff --git a/polycules.py b/polycules.py index 4874a90..a26b88b 100644 --- a/polycules.py +++ b/polycules.py @@ -309,7 +309,12 @@ def export_png(polycule_id): return Response(png, mimetype="image/png") -if __name__ == "__main__": + +run_directly = __name__ == "__main__" +run_gunicorn = __name__ == "polycules" + +if run_directly or run_gunicorn: migrate() - app.run(host=IP) + if run_directly: + app.run(host=IP) diff --git a/requirements.txt b/requirements.txt index b95304e..1c4dcd6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -35,7 +35,7 @@ requests==2.22.0 retrying==1.3.3 six==1.14.0 toml==0.10.1 -typed-ast==1.4.1 +typed-ast==1.5.5 urllib3==1.25.8 webencodings==0.5.1 Werkzeug==1.0.1