Update OPENCODE.md with Dockerfile docs and CI/CD information

Changes:
- Add Dockerfile Configuration section with code example
- Document Debian-based image choice (python:3.11-slim)
- Add all system dependencies (libgl1, libsm6, etc.)
- Extend Common Issues with Docker build troubleshooting
- New CI/CD section for Gitea Actions
- Document both workflows (autobuild and manual)
- Add required secrets and registry configuration
- Add version history overview
This commit is contained in:
2026-03-25 09:36:06 +00:00
parent 5488395a14
commit 67c85ff8a0

View File

@@ -13,25 +13,31 @@ This is a Telegram bot for managing sticker packs. Built with python-telegram-bo
- **Video Processing**: FFmpeg for GIF to WebM conversion
- **Background Removal**: rembg (local) + remove.bg API (optional)
- **Container**: Docker + Docker Compose
- **Base Image**: python:3.11-slim (Debian-based for better compatibility)
- **Environment**: python-dotenv for configuration
### Project Structure
```
stickerbot/
├── bot.py # Main bot with ConversationHandler
├── config.py # Configuration and environment loading
├── database.py # SQLite database operations
├── sticker_manager.py # Sticker management utilities
├── image_processor.py # Automatic image conversion
├── gif_processor.py # GIF to WebM conversion
├── background_remover.py # Background removal (local + API)
├── requirements.txt # Python dependencies
├── Dockerfile # Docker image configuration
├── docker-compose.yml # Docker Compose configuration
├── .env.example # Environment template
└── data/ # Persistent data directory
### Dockerfile Configuration
```dockerfile
FROM python:3.11-slim
# System dependencies for OpenCV, FFmpeg and rembg
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
```
**Key points:**
- Uses `python:3.11-slim` (Debian-based) instead of Alpine for better Python package compatibility
- Includes OpenCV dependencies: `libgl1`, `libglib2.0-0`, `libsm6`, `libxext6`, `libxrender-dev`
- Includes `libgomp1` for OpenMP support (required by numba/llvmlite)
- Non-root user for security
### Database Schema
- **sticker_sets**: Tracks created sticker sets (user_id, set_name, set_title, timestamps)
- **user_premium**: Caches user premium status with last check timestamp
@@ -321,9 +327,21 @@ sudo docker-compose up -d --build --force-recreate
5. **API limit reached**: Check current usage with `/hilfe` or in database
6. **Background removal slow**: First run downloads ML model (~180MB)
7. **GIF conversion fails**: Ensure GIF is under 10MB before upload
8. **Docker build fails with Alpine**: We use `python:3.11-slim` (Debian) instead of Alpine because rembg requires compilation tools that don't work well with Alpine's musl libc
## Troubleshooting
### Docker Build Issues
If the Docker build fails with package errors:
```bash
# The Dockerfile uses Debian-based python:3.11-slim
# NOT Alpine - this is intentional for better Python package compatibility
# Check Dockerfile has correct base image:
grep "FROM" Dockerfile
# Should show: FROM python:3.11-slim
```
### Bot not responding
```bash
# Check if container is running
@@ -344,3 +362,59 @@ sudo docker-compose restart
- Verify REMOVE_BG_API_KEY is correct
- Check API usage in database: `sqlite3 data/sticker_bot.db "SELECT * FROM api_usage;"`
- API automatically falls back to local processing on errors
## CI/CD with Gitea Actions
The project includes automated Docker builds via Gitea Actions.
### Workflow Files
**`.gitea/workflows/docker-autobuild.yaml`** - Automatic builds on push
- Triggers on push to `main` or `master` branch
- Builds and pushes to local registry: `192.168.88.201:5000`
- Tags: `latest` and `v{run_number}-autobuild`
- Features:
- Path ignores for markdown/docs changes
- Docker Buildx with layer caching
- Automatic cleanup after build
**`.gitea/workflows/docker-build.yaml`** - Manual builds
- Triggered manually via Gitea web interface
- Options:
- Custom version tag (e.g., `1.0.0`, `v1.0.0`)
- Additional tags (comma-separated, e.g., `stable,production`)
- Toggle `latest` tag
- Features:
- Flexible versioning
- Multiple tag support
- Docker layer caching
### Required Secrets
Configure these in Gitea repository settings:
- `REGISTRY_USERNAME` - Username for Docker registry
- `REGISTRY_PASSWORD` - Password for Docker registry
### Registry Configuration
Default registry: `192.168.88.201:5000`
To change the registry, edit both workflow files:
```yaml
REGISTRY="your-registry:port"
```
## Version History
See git log for detailed commit history:
```bash
git log --oneline
```
Current features:
- ✅ Telegram Sticker Bot with full management capabilities
- ✅ Automatic image optimization (WebP conversion)
- ✅ GIF to Video Sticker conversion
- ✅ Background removal (local + API)
- ✅ Existing sticker set import
- ✅ Gitea Actions CI/CD