Skip to content

Instantly share code, notes, and snippets.

@flyingwebie
Last active October 16, 2025 00:38
Show Gist options
  • Save flyingwebie/cbc29cccfeae8469f0a9a289fa419dd2 to your computer and use it in GitHub Desktop.
Save flyingwebie/cbc29cccfeae8469f0a9a289fa419dd2 to your computer and use it in GitHub Desktop.
Use "Docker Compose Empty" in Coolify -> Add your API keys for AWS SES and GitHub + Add the traefik-certs-dumper in the settings and you're ready to roll
services:
postgres:
image: 'postgres:16'
environment:
- 'POSTGRES_USER=${SERVICE_USER_POSTGRES}'
- 'POSTGRES_PASSWORD=${SERVICE_PASSWORD_POSTGRES}'
- 'POSTGRES_DB=${SERVICE_DB_POSTGRES:-usesend}'
healthcheck:
test:
- CMD-SHELL
- 'pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}'
interval: 5s
timeout: 20s
retries: 10
volumes:
- 'usesend-postgres-data:/var/lib/postgresql/data'
redis:
image: 'redis:7'
volumes:
- 'usesend-redis-data:/data'
command:
- redis-server
- '--maxmemory-policy'
- noeviction
healthcheck:
test:
- CMD
- redis-cli
- PING
interval: 5s
timeout: 10s
retries: 20
usesend:
image: 'usesend/usesend:latest'
expose:
- 3000
environment:
- SERVICE_URL_USESEND_3000
- 'DATABASE_URL=postgresql://${SERVICE_USER_POSTGRES}:${SERVICE_PASSWORD_POSTGRES}@postgres:5432/${SERVICE_DB_POSTGRES:-usesend}'
- 'NEXTAUTH_URL=${SERVICE_URL_USESEND}'
- 'NEXTAUTH_SECRET=${SERVICE_BASE64_64_NEXTAUTHSECRET}'
- 'AWS_ACCESS_KEY=${AWS_ACCESS_KEY:?}'
- 'AWS_SECRET_KEY=${AWS_SECRET_KEY:?}'
- 'AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:?}'
- 'GITHUB_ID=${GITHUB_ID:?}'
- 'GITHUB_SECRET=${GITHUB_SECRET:?}'
- 'REDIS_URL=redis://redis:6379'
- 'NEXT_PUBLIC_IS_CLOUD=${NEXT_PUBLIC_IS_CLOUD:-false}'
- 'API_RATE_LIMIT=${API_RATE_LIMIT:-1}'
- HOSTNAME=0.0.0.0
- 'SMTP_HOST=${SMTP_HOST-send.example.com}'
- 'SMTP_USER=${SMTP_AUTH_USERNAME-usesend}'
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test:
- CMD-SHELL
- 'wget -qO- http://usesend:3000 || exit 1'
interval: 5s
retries: 10
timeout: 2s
smtp-server:
container_name: usesend-smtp-server
image: 'usesend/smtp-proxy:latest'
volumes:
- '/data/coolify/certs/send.example.com:/data/certs:ro'
environment:
- SMTP_AUTH_USERNAME=usesend
- USESEND_BASE_URL=https://send.example.com
- USESEND_API_KEY_PATH=/data/certs/key.pem
- USESEND_API_CERT_PATH=/data/certs/cert.pem
expose:
- 25
- 587
- 2587
- 465
- 2465
ports:
- '25:25'
- '587:587'
- '2587:2587'
- '465:465'
- '2465:2465'
labels:
- 'traefik.tcp.routers.smtp.rule=HostSNI(`*`)'
- traefik.tcp.routers.smtp.entrypoints=smtp
- traefik.tcp.routers.smtp.service=smtp
- traefik.tcp.services.smtp.loadbalancer.server.port=25
- 'traefik.tcp.routers.smtps.rule=HostSNI(`*`)'
- traefik.tcp.routers.smtps.tls.passthrough=true
- traefik.tcp.routers.smtps.entrypoints=smtps
- traefik.tcp.routers.smtps.service=smtps
- traefik.tcp.services.smtps.loadbalancer.server.port=465
- traefik.tcp.services.smtps.loadbalancer.proxyProtocol.version=2
healthcheck:
test:
- CMD-SHELL
- "echo QUIT | nc -w 5 localhost 25 | grep -q '^220'"
interval: 30s
timeout: 10s
retries: 3
@flyingwebie
Copy link
Author

flyingwebie commented Oct 15, 2025

I originally started messing with Traefik labels at the server level, but it turned out I didn’t need to. I followed Aldert’s lead making sure that the server’s certificates could be available for the relay to use by appending the following to the Traefik configuration in
Server → Proxy → Configuration

traefik-certs-dumper:
  image: ghcr.io/kereis/traefik-certs-dumper:latest
  container_name: traefik-certs-dumper
  restart: unless-stopped
  depends_on:
    - traefik
  volumes:
    - /etc/localtime:/etc/localtime:ro
    - /data/coolify/proxy:/traefik:ro
    - /data/coolify/certs:/output

IMPORTANT

traefik-certs-dumper could not generate the certificate in time so I restart the container and it will create the new certificaes

$ docker restart traefik-certs-dumper

@flyingwebie
Copy link
Author

flyingwebie commented Oct 15, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment