From bc54e1856c09c8976ed89455cb09ba0f9abc2f03 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sun, 27 Nov 2022 10:54:01 -0700 Subject: [PATCH] Update docker-compose and instructions --- Makefile | 6 ++++ docker/docker-compose.yml | 12 +++++--- docs/contributing.rst | 63 +++++++++++++++++++++++---------------- 3 files changed, 52 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index e75c845..26680ff 100644 --- a/Makefile +++ b/Makefile @@ -6,5 +6,11 @@ image: docs: cd docs/ && make html +compose_build: + docker-compose -f docker/docker-compose.yml build + compose_up: docker-compose -f docker/docker-compose.yml up + +compose_down: + docker-compose -f docker/docker-compose.yml down diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 3949f56..f9b89e5 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -12,11 +12,11 @@ x-takahe-common: image: takahe:latest environment: - TAKAHE_DATABASE_URL: "postgres://postgres:insecure_password@db/takahe" - TAKAHE_DEBUG: true + TAKAHE_DATABASE_SERVER: "postgres://postgres:insecure_password@db/takahe" + TAKAHE_DEBUG: "true" TAKAHE_SECRET_KEY: "insecure_secret" TAKAHE_CSRF_TRUSTED_ORIGINS: '["http://127.0.0.1:8000", "https://127.0.0.1:8000"]' - TAKAHE_USE_PROXY_HEADERS: true + TAKAHE_USE_PROXY_HEADERS: "true" TAKAHE_EMAIL_BACKEND: "console://console" TAKAHE_MAIN_DOMAIN: "example.com" TAKAHE_ENVIRONMENT: "development" @@ -31,7 +31,7 @@ x-takahe-common: services: db: - image: postgres:15-alpine + image: docker.io/postgres:15-alpine healthcheck: test: ['CMD', 'pg_isready', '-U', 'postgres'] volumes: @@ -49,6 +49,10 @@ services: ports: - "8000:8000" + stator: + <<: *takahe-common + command: ["/takahe/manage.py", "runstator"] + setup: <<: *takahe-common command: ["/takahe/manage.py", "migrate"] diff --git a/docs/contributing.rst b/docs/contributing.rst index 3cfb890..34a93a7 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -30,6 +30,42 @@ and local posting/follow functionality; to test ActivityPub itself and follow other people, your installation **must be accessible from the internet**; doing that securely is different enough per person that it is not covered here. +Using Docker Compose is the fastest way to get up and running, and you will +still be able to make web changes and have them appear in real-time. Direct +installation is recommended for more advanced developers or those wishing to +use a PostgreSQL they already have. + +These instructions are not suitable for running a production copy; for that, +see :doc:`installation`. + +Docker +~~~~~~ + +The docker build process will take care of much of the above, but you just have +to be sure that you're executing it from the project root. + +First, you need to build your image:: + + docker compose -f docker/docker-compose.yml build + +Then start the ``compose`` session:: + + docker compose -f docker/docker-compose.yml up + +At this point, you should be able to see the Web UI at http://localhost:8000 + +Once your session is up and running, you can make yourself a superuser account:: + + docker compose -f docker/docker-compose.yml exec web manage.py createsuperuser + +And you can run the tests inside your container:: + + docker compose -f docker/docker-compose.yml exec web pytest + +If you want to change the settings that Takahē is using, you can edit them +near the top of the docker-compose file; the default set are designed for a +local installation, though. + Direct installation ~~~~~~~~~~~~~~~~~~~ @@ -48,7 +84,7 @@ Then install the development requirements:: pip install -r requirements-dev.txt -and enable the git commit hooks to do auto-formatting and linting +Enable the git commit hooks to do auto-formatting and linting (if you don't do this, our CI system will reject your PRs until they match):: pre-commit install @@ -73,30 +109,7 @@ And you can run the tests with pytest:: pytest - -Docker -~~~~~~ - -The docker build process will take care of much of the above, but you just have -to be sure that you're executing it from the project root. - -First, you need to build your image:: - - docker compose -f docker/docker-compose.yml build - -Then start the `compose` session:: - - docker compose -f docker/docker-compose.yml up - -At this point, you will be able to see the Web UI at http://localhost:8000 - -Once your session is up and running, you can make yourself a superuser account:: - - docker compose -f docker/docker-compose.yml exec web manage.py createsuperuser - -And you can run the tests inside your container:: - - docker compose -f docker/docker-compose.yml exec web pytest +If you want to edit settings, you can edit the ``.env`` file. Coding Guidelines