This guide explains how to start the development environment for the project using Docker Compose. It includes setting up the backend and database.
- Docker installed on your machine (v20+ recommended).
- Docker Compose installed (v20+ recommended).
- Ensure port 5433 is available for the PostgreSQL container.
-
Clone the Repository
git clone <repository-url> cd <repository-folder>
-
Provide all required env variables Provide all variables from
.env.dev.example
# Django
SECRET_KEY=#
# PostgreSQL
DB_NAME=postgres
DB_USER=postgres
DB_PASSWORD=#
DB_HOST=db
# Github
GITHUB_AUTH_TOKEN=#
# Telegram
TELEGRAM_BOT_TOKEN=#
-
Build and Start Services
To build and run the entire development environment, use the following command:
docker-compose -f docker-compose.dev.yaml up -d --build
This command will:
- Build the backend and DB Docker images.
- Start the backend and PostgreSQL database containers.
-
Access the Application
- Backend API: Accessible at http://localhost:8000.
- PostgreSQL Database: Accessible at
localhost:5433(make sure to use theDB_USERandDB_PASSWORDfrom the.envfile).
To stop the environment and remove containers, use:
docker-compose -f docker-compose.dev.yaml downThis command stops all running containers and removes them, but the data volumes will persist.
If you have made changes to the code or Docker configuration, rebuild the containers:
docker-compose -f docker-compose.dev.yaml up -d --build- Enter your virtual environment
- Ensure you have installed poetry inside your venv
- Install all dependencies
poetry install
- Run command to create migration file
python manage.py makemigrations
To apply migrations and update the database schema, use:
python manage.py migrateTo revert the last migration, use:
python manage.py migrate app_name <previous_migration_name>Replace app_name with the name of your app and <previous_migration_name> with the name of the migration you want to revert to.
To get a GitHub API key, follow these steps:
- Go to GitHub Settings
- Navigate to Developer settings
- Click on
Personal access tokens - Generate a new token with the required scopes.
For more information, you can refer to the GitHub documentation.
To get a Telegram API key, follow these steps:
- Open Telegram and search for the BotFather
- Start a chat with BotFather and create a new bot using the
/newbotcommand. - Follow the instructions to get your API token.