This guide covers deploying Leafmark to production using Coolify on a self-hosted server.
- A server (VPS) with Docker installed
- Coolify installed and configured
- A domain name (e.g.,
leafmark.app) - Cloudflare account (optional, for CDN/SSL)
User β Cloudflare (CDN/SSL) β Server β Coolify/Traefik β Leafmark Container
β
MariaDB Container
- Go to Projects β Add Project
- Name:
Leafmark - Click Add Resource β Public Repository
- Repository URL:
https://github.com/roberteinsle/leafmark - Branch:
main - Build Pack:
Dockerfile(auto-detected)
Add these environment variables in Coolify:
APP_NAME=Leafmark
APP_ENV=production
APP_DEBUG=false
APP_URL=https://www.leafmark.app
DB_CONNECTION=mysql
DB_HOST=leafmark-db
DB_PORT=3306
DB_DATABASE=leafmark
DB_USERNAME=leafmark
DB_PASSWORD=<secure-password>
# Optional API Keys
GOOGLE_BOOKS_API_KEY=<your-key>
ISBNDB_API_KEY=<your-key>Add a MariaDB service in the same project:
- Add Resource β Database β MariaDB
- Name:
leafmark-db - Configure credentials to match your environment variables
- Domain:
www.leafmark.app - Proxy: Select
Cloudflareif using Cloudflare
Click Deploy β Coolify will:
- Clone the repository
- Build the Docker image
- Start the container
- Configure the reverse proxy
Add these DNS records:
| Type | Name | Content | Proxy |
|---|---|---|---|
| A | @ | <server-ip> |
Proxied (orange) |
| CNAME | www | leafmark.app |
Proxied (orange) |
In Cloudflare Rules β Redirect Rules:
- When: Hostname equals
leafmark.app - Then: Redirect to
https://www.leafmark.app(301)
- In Coolify, select Cloudflare as proxy type
- In Cloudflare SSL/TLS settings, set to Full (strict)
Coolify will automatically generate Let's Encrypt certificates.
In Coolify, use the Terminal tab or SSH into the container:
docker exec -it <container-id> php artisan migrate --forcedocker exec -it <container-id> php artisan key:generatedocker exec -it <container-id> php artisan config:cache
docker exec -it <container-id> php artisan route:cache
docker exec -it <container-id> php artisan view:cacheCoolify automatically sets up a webhook. Every push to main triggers a new deployment.
To disable auto-deploy:
- Go to your resource in Coolify
- Settings β Disable Auto Deploy
In Coolify: Resources β Leafmark β Logs
Or via SSH:
docker logs -f <container-id>The app exposes a health endpoint:
curl https://www.leafmark.app/healthdocker exec leafmark-db mysqldump -u leafmark -p leafmark > backup.sql- Go to S3 Storages in Coolify
- Configure your S3-compatible storage
- Enable backups for your database service
Check logs in Coolify or:
docker logs <container-id>- Check if the container is running
- Verify the port configuration
- Check Traefik logs:
docker logs coolify-proxy
- Verify DB_HOST matches the database container name
- Check if database container is running
- Verify credentials match
# Enter container shell
docker exec -it <container-id> bash
# Run artisan commands
docker exec -it <container-id> php artisan <command>
# View real-time logs
docker logs -f <container-id>
# Restart container
docker restart <container-id>