This guide will cover the steps needed to get The Cogito backend environment set up using Docker.
Before you begin, ensure that you have the following installed:
These tools are required to create your containerized environment.
Navigate to the root of the project where the docker-compose.yml
file is located.
Then run the following commands to build and start your Docker containers:
docker compose build # This command builds the Docker images defined in your docker-compose.yml file.
docker compose up # This command starts the containers in the foreground. Add -d to run them in the background.
After running docker-compose up, your Django application should be accessible via http://localhost:8000
or another port specified in your Docker configuration.
To stop your Docker containers, you can use:
docker compose down
To view the status of your Docker containers, you can use:
docker ps
To run Django commands, you can use the following command:
docker compose run cogito python manage.py <command>
Replace <command>
with the Django command you want to run.
So to run tests, you can use:
docker compose run cogito python manage.py test
To run Django migrations, you can use the following command:
docker compose run cogito python manage.py makemigrations
docker compose run cogito python manage.py migrate
To log into the django database, create a superuser
docker-compose run cogito python manage.py createsuperuser