4.3 KiB
4.3 KiB
Environment Setup Guide
This guide explains how to configure environment variables for your Hetzner deployment.
Quick Start
-
Copy the example file:
cp .env.example .env -
Edit the .env file:
nano .env -
Fill in your values (see below)
Required Variables
DOMAIN
Your website domain name.
DOMAIN=mintel.me
ADMIN_EMAIL
Email for SSL certificate notifications.
ADMIN_EMAIL=admin@mintel.me
Optional Variables
REDIS_URL
Connection string for Redis cache.
- Default:
redis://redis:6379 - Format:
redis://host:port - Example:
redis://redis:6379
PLAUSIBLE_DOMAIN
Domain for Plausible analytics tracking.
- Default: Same as
DOMAIN - Example:
mintel.me
PLAUSIBLE_SCRIPT_URL
URL to your Plausible analytics script.
- Default:
https://plausible.yourdomain.com/js/script.js - Example:
https://analytics.mintel.me/js/script.js
Woodpecker CI/CD Variables
These are only needed if using Woodpecker for automated deployment:
DEPLOY_HOST
Hetzner server IP address or hostname.
DEPLOY_HOST=123.45.67.89
DEPLOY_USER
User for SSH access (usually root).
DEPLOY_USER=root
SSH_PRIVATE_KEY
Private key for SSH authentication.
SSH_PRIVATE_KEY=-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----
Generate SSH key if needed:
ssh-keygen -t ed25519 -C "woodpecker@mintel.me"
ssh-copy-id root@YOUR_HETZNER_IP
SLACK_WEBHOOK (Optional)
Slack webhook for deployment notifications.
SLACK_WEBHOOK=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
Usage Examples
Local Development
# Create .env file
cp .env.example .env
# Edit with your values
nano .env
# Start services
docker-compose up
Production Deployment
# On Hetzner server
cd /opt/mintel
# Create .env file
cat > .env << EOF
DOMAIN=mintel.me
ADMIN_EMAIL=admin@mintel.me
REDIS_URL=redis://redis:6379
PLAUSIBLE_DOMAIN=mintel.me
PLAUSIBLE_SCRIPT_URL=https://analytics.mintel.me/js/script.js
EOF
# Deploy
./deploy.sh
Woodpecker CI/CD
- Go to your Gitea repository
- Navigate to Settings → Secrets
- Add these secrets:
DEPLOY_HOST- Your Hetzner IPDEPLOY_USER- UsuallyrootSSH_PRIVATE_KEY- Private key contentDOMAIN- Your domainADMIN_EMAIL- Your email- (Optional)
SLACK_WEBHOOK
Security Notes
- Never commit
.envfile to git (it's in.gitignore) - Keep SSH keys secure and never share
- Use strong passwords for all services
- Enable firewall on Hetzner server
Troubleshooting
Variables not loading
# Check if .env file exists
ls -la .env
# Check file permissions
chmod 600 .env
# Verify variables
cat .env
Docker Compose not using .env
# Explicitly specify env file
docker-compose --env-file .env up
# Or check if it's being loaded
docker-compose config
Woodpecker secrets not working
- Verify secret names match exactly
- Check repository settings
- Restart Woodpecker agent
- Check Woodpecker logs
Environment-Specific Configurations
Development
# .env
DOMAIN=localhost:3000
ADMIN_EMAIL=dev@localhost
REDIS_URL=redis://localhost:6379
Staging
# .env
DOMAIN=staging.mintel.me
ADMIN_EMAIL=staging@mintel.me
REDIS_URL=redis://redis:6379
Production
# .env
DOMAIN=mintel.me
ADMIN_EMAIL=admin@mintel.me
REDIS_URL=redis://redis:6379
PLAUSIBLE_DOMAIN=mintel.me
PLAUSIBLE_SCRIPT_URL=https://analytics.mintel.me/js/script.js
Available Variables Reference
| Variable | Required | Default | Description |
|---|---|---|---|
DOMAIN |
✅ Yes | - | Website domain |
ADMIN_EMAIL |
✅ Yes | - | SSL contact email |
REDIS_URL |
❌ No | redis://redis:6379 |
Redis connection |
PLAUSIBLE_DOMAIN |
❌ No | Same as DOMAIN |
Analytics domain |
PLAUSIBLE_SCRIPT_URL |
❌ No | Plausible default | Analytics script URL |
DEPLOY_HOST |
CI Only | - | Hetzner server IP |
DEPLOY_USER |
CI Only | root |
SSH user |
SSH_PRIVATE_KEY |
CI Only | - | SSH private key |
SLACK_WEBHOOK |
❌ No | - | Slack notifications |
Next: Run ./deploy.sh or push to trigger CI/CD deployment!