From d7e9de5f61b67c6d4307314aad3d6548f1638e5c Mon Sep 17 00:00:00 2001 From: Max Erenberg <> Date: Fri, 17 Sep 2021 22:29:34 -0400 Subject: [PATCH] install virtualenv on host --- .drone/auth1-setup.sh | 6 +++++- README.md | 14 +++++++++++--- docker-compose.yml | 2 +- docker-entrypoint.sh | 12 +++++++++--- tests/MockMailmanServer.py | 8 ++++---- tests/ceod_test_local.ini | 4 ++-- 6 files changed, 32 insertions(+), 14 deletions(-) diff --git a/.drone/auth1-setup.sh b/.drone/auth1-setup.sh index a96d017..53f52f2 100755 --- a/.drone/auth1-setup.sh +++ b/.drone/auth1-setup.sh @@ -46,7 +46,11 @@ cp .drone/nsswitch.conf /etc/nsswitch.conf service nslcd start ldapadd -c -f .drone/data.ldif -Y EXTERNAL -H ldapi:/// if [ -z "$CI" ]; then - ldapadd -c -f .drone/uwldap_data.ldif -Y EXTERNAL -H ldapi:/// ||: + ldapadd -c -f .drone/uwldap_data.ldif -Y EXTERNAL -H ldapi:/// || true + # setup ldapvi for convenience + apt install -y vim ldapvi + echo 'export EDITOR=vim' >> /root/.bashrc + echo 'alias ldapvi="ldapvi -Y EXTERNAL -h ldapi:///"' >> /root/.bashrc fi # KERBEROS diff --git a/README.md b/README.md index 771f798..ef3e47d 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,15 @@ overview of its architecture. ### Docker If you are not modifying code related to email or Mailman, then you may use Docker containers instead, which are much easier to work with than the VM. + +First, make sure you create the virtualenv: +```sh +docker run --rm -v "$PWD:$PWD" -w "$PWD" -u $(id -u):$(id -g) python:3.7-buster \ + sh -c 'python -m venv venv && . venv/bin/activate && pip install -r requirements.txt -r dev-requirements.txt' ``` -docker-compose up -d # or without -d to run in the foreground +Then bring up the containers: +```sh +docker-compose up -d # or without -d to run in the foreground ``` This will create some containers with the bare minimum necessary for ceod to run, and start ceod on each of phosphoric-acid, mail, and coffee container. @@ -23,7 +30,8 @@ To use ceo, run the following: ```sh docker-compose exec phosphoric-acid bash su ctdalek -python -m ceo # the password for kerobos is krb5 +. venv/bin/activate +python -m ceo # the password is krb5 ``` This should bring up the TUI. @@ -162,7 +170,7 @@ pip install -r requirements.txt pip install -r dev-requirements.txt ``` -## Running the application +#### Running the application ceod is a distributed application, with instances on different hosts offering different services. Therefore, you will need to run ceod on multiple hosts. Currently, those are diff --git a/docker-compose.yml b/docker-compose.yml index 7c4ea6f..324d324 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: auth1: <<: *common image: debian:buster - hostname: auth0 + hostname: auth1 command: auth1 coffee: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 8d430b2..9f19ecb 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,10 +1,16 @@ #!/bin/sh -e + +if ! [ -d venv ]; then + echo "You need to create the virtualenv first!" >&2 + exit 1 +fi + host="$1" -[ -x ".drone/$host-setup.sh" ] && "./.drone/$host-setup.sh" +[ -x ".drone/$host-setup.sh" ] && ".drone/$host-setup.sh" if [ "$host" = auth1 ]; then exec sleep infinity else - python3 -m pip install -r requirements.txt -r dev-requirements.txt - exec ./.drone/supervise.sh flask run -h 0.0.0.0 -p 9987 + . venv/bin/activate + exec .drone/supervise.sh flask run -h 0.0.0.0 -p 9987 fi diff --git a/tests/MockMailmanServer.py b/tests/MockMailmanServer.py index d2a3f02..d6ff78b 100644 --- a/tests/MockMailmanServer.py +++ b/tests/MockMailmanServer.py @@ -4,12 +4,12 @@ from aiohttp import web class MockMailmanServer: - def __init__(self, port=8002): + def __init__(self, port=8001, prefix='/3.1'): self.port = port self.app = web.Application() self.app.add_routes([ - web.post('/members', self.subscribe), - web.delete('/lists/{mailing_list}/member/{address}', self.unsubscribe), + web.post(prefix + '/members', self.subscribe), + web.delete(prefix + '/lists/{mailing_list}/member/{address}', self.unsubscribe), ]) self.runner = web.AppRunner(self.app) self.loop = asyncio.new_event_loop() @@ -71,5 +71,5 @@ class MockMailmanServer: if __name__ == '__main__': - server = MockMailmanServer(8001) + server = MockMailmanServer() server.start() diff --git a/tests/ceod_test_local.ini b/tests/ceod_test_local.ini index 25d9dae..7927654 100644 --- a/tests/ceod_test_local.ini +++ b/tests/ceod_test_local.ini @@ -9,7 +9,7 @@ fs_root_host = phosphoric-acid mailman_host = phosphoric-acid database_host = phosphoric-acid use_https = false -port = 9987 +port = 9988 [ldap] admin_principal = ceod/admin @@ -40,7 +40,7 @@ smtp_url = smtp://localhost:8025 smtp_starttls = false [mailman3] -api_base_url = http://localhost:8002 +api_base_url = http://localhost:8001/3.1 api_username = restadmin api_password = mailman3 new_member_list = csc-general