|
| 1 | +# Deployment on test or production environments |
| 2 | + |
| 3 | +## Development in docker container |
| 4 | + |
| 5 | +Copy env templates: |
| 6 | + |
| 7 | +- Copy `.env-template` to `.env` |
| 8 | +- Copy `.env.django-template` to `.env.django` |
| 9 | +- Copy `.env.django.db-template` to `.env.django.db` |
| 10 | + |
| 11 | +Adjust settings in env files as needed. |
| 12 | + |
| 13 | +Run the docker development container: |
| 14 | + |
| 15 | + docker-compose up -d |
| 16 | + |
| 17 | +(You can use `--build` to force rebuilding the docker container) |
| 18 | + |
| 19 | +There are two ways to debug django inside the container. |
| 20 | + |
| 21 | +1: Debug using by connecting to the remote docker and just debug a django project as usual. |
| 22 | +E.g. in Visual Studio Code: install extension: Visual Studio Code Remote - Containers |
| 23 | +Then connect to the remote md-api-dvl_django_1 container. |
| 24 | +You can now start a debugging session as usual |
| 25 | + |
| 26 | +Note that you can add the /srv/project_root folder as workspace folder so you can use |
| 27 | +the git functionality in the IDE as well |
| 28 | + |
| 29 | +2: The one that isn't all that great uses debugpy. You can read more about it here: |
| 30 | +To debug a running container, see: [Debugging a Containerized Django App in VS Code](https://testdriven.io/blog/django-debugging-vs-code/) |
| 31 | + |
| 32 | +## Development in using local python |
| 33 | + |
| 34 | +Set-up and enable [pyenv](https://github.com/pyenv/pyenv#getting-pyenv) and |
| 35 | +[pyenv-virtual-env](https://github.com/pyenv/pyenv-virtualenv#installation): |
| 36 | + |
| 37 | + pyenv install --list |
| 38 | + pyenv install 3.11.7 |
| 39 | + pyenv virtualenv 3.11.7 webhook_forwarder |
| 40 | + pyenv local webhook_forwarder__3.11.7 |
| 41 | + |
| 42 | +Clone git repo. For any other env than development make sure ssh agent |
| 43 | +forwarding is enabled. |
| 44 | + |
| 45 | + git clone [email protected]:pu/webhook_forwarder.git |
| 46 | + cd webhook_forwarder/src |
| 47 | + |
| 48 | +Create `.env` file based on `.env-sample` |
| 49 | + |
| 50 | +## Seting up dev env |
| 51 | + |
| 52 | +When django is used locally (not in a docker env) the `.env` file is used by Django. |
| 53 | + |
| 54 | +Rename `.env-template` to `.env` and adjust settings as needed. |
| 55 | + |
| 56 | +Install dependencies: |
| 57 | + |
| 58 | + pip install -r requirements/dev.txt |
| 59 | + |
| 60 | +Run migrations to initialize the database: |
| 61 | + |
| 62 | + python manage.py migrate |
| 63 | + |
| 64 | +Start development server: |
| 65 | + |
| 66 | + python manage.py runserver |
| 67 | + |
| 68 | +### Dramatiq message queue / RabbitMQ |
| 69 | + |
| 70 | +First start rabbitmq in a docker container: |
| 71 | + |
| 72 | + docker-compose up -d rabbitmq |
| 73 | + |
| 74 | +Start the dramatiq worker: |
| 75 | + |
| 76 | + ./manage.py rundramatiq --threads 2 --processes 1 --reload |
| 77 | + |
| 78 | +Start the periodiq (cron replacement) scheduler: |
| 79 | + |
| 80 | + ./manage.py runperiodiq |
| 81 | + |
| 82 | +Task queue progress is available in Django admin |
| 83 | +[http://localhost:8000/admin/django_dramatiq/task/](http://localhost:8000/admin/django_dramatiq/task/). |
| 84 | + |
| 85 | + |
0 commit comments