This repository is optimized for deployment on Coolify using Docker. It includes a pre-configured Dockerfile with all necessary system dependencies for Face Recognition (dlib) and OpenCV.
- Go to your Coolify Dashboard.
- Click + New Resource.
- Select Public Repository (or Private if you keep this private).
- Enter your GitHub repository URL.
- Build Pack: Keep as
Dockerfile.
Before hitting "Deploy", go to the Configuration tab of your new service:
- Port:
8501 - Domains: Set your domain (e.g.,
https://face-system.yourdomain.com).⚠️ HTTPS IS MANDATORY: WebRTC (Camera access) will not work without a valid HTTPS connection.
You MUST configure these volumes to ensure user data and logs survive redeployments.
| Volume Name / Host Path | Container Path | Description |
|---|---|---|
known_faces |
/app/known_faces |
Stores registered faces |
logs |
/app/logs |
Stores attendance logs |
- Go to Storage.
- Click Add Storage.
- Add VOLUME for
/app/known_faces. - Add VOLUME for
/app/logs.
Why directory mounts?
Mounting directories (e.g., /app/logs) is safer than single files in Docker/Coolify. The app will automatically create factory_logs.csv inside the logs folder.
Click Deploy. The build process might take a few minutes as it compiles dlib.
Dockerfile: Python 3.10 + build-essential + cmake + app.requirements.txt: Python deps (headless opencv).main.py: Core application.known_faces/: directory for face images.
- Build Failures: Ensure the Dockerfile includes
cmakeandbuild-essential(already included). - Camera Not Working: Ensure you are accessing via
https://config in Coolify. - "Connecting..." indefinitely: Ensure the port
8501is exposed and mapped correctly.
If the camera says "Connection is taking longer than expected...", your network (or the server's network) is blocking the P2P connection.
Solution: Add a TURN Server (Easiest Way - Metered.ca)
- Get your API URL: You already have it! It looks like:
https://camerafavouritefab.metered.live/api/v1/turn/credentials?apiKey=YOUR_API_KEY - In Coolify -> Service -> Environment Variables, add one simple variable:
ICE_SERVERS_URL:https://camerafavouritefab.metered.live/api/v1/turn/credentials?apiKey=f43166290d8713f4fce8b3ad0dc68e8de0e2(Replace with your full URL if different).
- Redeploy.
The app will now automatically fetch the fresh TURN credentials from that URL every time it starts. This is much more reliable than hardcoding passwords.
Why is this needed? WebRTC tries to connect Peer-to-Peer. Corporate firewalls, Cloudflare Tunnels, and Docker containers often block this. A TURN server relays the traffic around the blockage.