┌─────────────────────────────────────────────────────────┐
│ SERVER (VPS + Coolify) │
│ ┌─────────────────┐ ┌─────────────────────────┐ │
│ │ Python Bot │◄────►│ PostgreSQL Database │ │
│ │ (Docker) │ │ (Coolify service) │ │
│ └─────────────────┘ └─────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
▲
│ sync
▼
┌─────────────────┐
│ Rust TUI App │
│ (your laptop) │
└─────────────────┘
- A VPS with Coolify installed
- A Telegram account
- Open Telegram, search for @BotFather
- Send
/newbot - Choose a name:
Pilotage Survie Bot - Choose a username:
pilotage_survie_bot(must end inbot) - Save the token you receive
- Search for @userinfobot on Telegram
- Send
/start - Save your Chat ID
- Go to your Coolify dashboard
- Click + New Resource → Database → PostgreSQL
- Configure:
- Name:
pilotage-db - Database:
pilotage_survie - Username:
pilotage - Password: (generate a strong one)
- Name:
- Click Deploy
- Once running, copy the Internal URL (looks like
postgresql://pilotage:xxx@pilotage-db:5432/pilotage_survie)
Connect to your PostgreSQL container and run schema.sql:
# In Coolify, open the database terminal or use:
psql -U pilotage -d pilotage_survie
# Then paste the contents of schema.sqlOr upload schema.sql and run:
psql -U pilotage -d pilotage_survie -f schema.sql- Push
telegram_bot/to a Git repo (GitHub, GitLab, etc.) - In Coolify: + New Resource → Application → Docker
- Connect your Git repository
- Set the build context to
telegram_bot/(or root if separate repo) - Add environment variables (see below)
- Deploy
- In Coolify: + New Resource → Docker Compose
- Paste this configuration:
services:
pilotage-bot:
build: .
restart: always
environment:
- TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN}
- TELEGRAM_CHAT_ID=${TELEGRAM_CHAT_ID}
- DATABASE_URL=${DATABASE_URL}
- TIMEZONE=${TIMEZONE}
depends_on:
- db
db:
image: postgres:15-alpine
restart: always
environment:
- POSTGRES_DB=pilotage_survie
- POSTGRES_USER=pilotage
- POSTGRES_PASSWORD=${DB_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data
- ./schema.sql:/docker-entrypoint-initdb.d/schema.sql
volumes:
postgres_data:In Coolify, add these environment variables:
| Variable | Value |
|---|---|
TELEGRAM_BOT_TOKEN |
Your bot token from BotFather |
TELEGRAM_CHAT_ID |
Your chat ID |
DATABASE_URL |
postgresql://pilotage:PASSWORD@pilotage-db:5432/pilotage_survie |
TIMEZONE |
Europe/Paris |
Create .env file in your Rust app folder:
DATABASE_URL=postgresql://pilotage:your_password@your-server-ip:5432/pilotage_survieIn Coolify, for your PostgreSQL service:
- Go to Settings → Network
- Enable Publicly Accessible or add a port mapping (5432)
- Or use Coolify's Proxy feature to expose the database
Alternatively, use SSH tunnel (more secure):
ssh -L 5432:localhost:5432 user@your-server-ipThen your local .env:
DATABASE_URL=postgresql://pilotage:your_password@localhost:5432/pilotage_surviecargo run -- --sync| Command | Description |
|---|---|
/start |
Welcome message |
/list |
Show today's tasks |
/add <title> |
Add a new task |
/done <id> |
Mark task as done |
/undone <id> |
Mark task as not done |
/delete <id> |
Delete a task |
/stats |
Show today's statistics |
/init |
Create default tasks |
/note <text> |
Add/update daily note |
- Go to your application → Logs tab
- Or click Terminal to access the container
- Click Restart in the application dashboard
- Push changes to Git → Coolify auto-deploys (if webhook configured)
- Or click Redeploy manually
- Coolify shows container status and resource usage
- Set up notifications in Coolify settings
- Check Coolify logs for errors
- Verify environment variables are set correctly
- Test database connection from bot container
# In bot container terminal:
python -c "from database import get_connection; print(get_connection())"- Check
TIMEZONEenvironment variable - Verify bot is running (check Coolify dashboard)
- Never commit
.envfiles to git - Use Coolify's Secrets for sensitive values
- Keep PostgreSQL internal (not publicly exposed) if possible
- Use SSH tunnel for laptop connection instead of exposing port 5432