Telegram whitelist bot for a chats
touch env/.env.localand set variables:- TELEGRAM_BOT_TOKEN
- TELEGRAM_ADMIN_GROUP_ID
docker compose builddocker compose updocker compose run migrator -e POSTGRES_URL up- If necessary,
sudo chmod u+x scripts/own_project.sh && ./scripts/own_project.sh
Additional steps for production:
- Create administrator user and perform all steps from him
- Set additional variables:
- ENVIRONMENT=production
- POSTGRES_PASSWORD
- POSTGRES_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_SERVER}:${POSTGRES_PORT}/${POSTGRES_DB}?sslmode=disable"
- REDIS_PASSWORD
- Use docker compose command with prod file:
docker compose -f docker-compose.yml -f docker-compose.prod.yml build - And run in background
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
- Set bot folder: RClick on ./bot -> Mark directory as -> Mark as Sources Root
- For Community version you can use local packages environment for packages mapping:
cd bot && python -m venv venv- In Pycharm set Python Interpreter as existing Virtual Environment using venv
source venv/bin/activatepython -m pip install virtualenvdeactivate
Deprecated due to the addition of auto-reload
Run compose and stop the bot containerdocker compose upThen in new terminal run
docker compose stop -t 1 bot && docker compose run --rm -p 3000:3000 botWorks like a ⚡️
Required depending on environment
Because Docker may run as root, you may need to take ownership of the project files after they are created from containers.For example, when creating a new migration with migrator.
To do so, use
./scripts/own_project.sh
Using dbmate as migration engine.
Create new migration with
docker compose run migrator -e POSTGRES_URL new create_users_table
Migrate with
docker compose run migrator -e POSTGRES_URL migrate
View help and rest of the commands with
docker compose run migrator --help
Commit migrator/db/schema.sql together with migrations after running dbmate locally or in a controlled development environment. Production should apply migrations without writing schema dumps back into the server checkout.
Don't forget to own the project if necessary.