- Start the stack with Docker Compose:
docker-compose up -d
- Now you can open your browser and interact with these URLs:
Backend, JSON based web API based on OpenAPI: http://localhost/api/
Automatic interactive documentation with Swagger UI (from the OpenAPI backend): http://localhost/docs
Note: The first time you start your stack, it might take a minute for it to be ready. While the backend waits for the database to be ready and configures everything. You can check the logs to monitor it.
To check the logs, run:
docker-compose logs
To check the logs of a specific service, add the name of the service, e.g.:
docker-compose logs wallet
By default, the dependencies are managed with PIP, go there and install it.
You can install all the dependencies with:
$ pip install -r requirements/requirements.txt
During development, you can change Docker Compose settings that will only affect the local development environment, in the file docker-compose.override.yml
.
The changes to that file only affect the local development environment, not the production environment. So, you can add "temporary" changes that help the development workflow.
$ docker-compose up -d
There is also a commented out command
override, you can uncomment it and comment the default one. It makes the backend container run a process that does "nothing", but keeps the container alive. That allows you to get inside your running container and execute commands inside, for example a Python interpreter to test installed dependencies, or start the development server that reloads when it detects changes, or start a Jupyter Notebook session.
To get inside the container with a bash
session you can start the stack with:
$ docker-compose up -d
and then exec
inside the running container:
$ docker-compose exec wallet bash
You should see an output like:
root@7f2607af31c3:/app#
that means that you are in a bash
session inside your container, as a root
user, under the /app
directory.
To test the backend run:
$ pytest .
If you use GitLab CI the tests will run automatically.
PIP_PACKAGES_FILE=requirements.dev.txt docker-compose build
You can rerun the test on live code:
docker exec wallet_maintenance pytest
Because the test scripts forward arguments to pytest
, you can enable test coverage HTML report generation by passing --cov-report=html
.
To run the local tests with coverage HTML reports:
pytest . --cov-report=html
To run the tests in a running stack with coverage HTML reports:
docker exec wallet_maintenance pytest . --cov-report=html