Production
Learn how to self-host Latitude in production mode
Starting Latitude with Docker Compose
Latitude can be easily deployed in a single machine using Docker Compose, which will set up all required services including the web interface, API gateway, workers, websockets, database, and Redis.
Prerequisites
- Docker and Docker Compose installed on your system
- A copy of the
.env
configuration file
Configuration
- First, create your environment configuration by copying the example file:
- Configure your
.env
file with your production settings. The following key configurations are available:
-
Database Settings:
POSTGRES_USER
andPOSTGRES_PASSWORD
: Database credentialsDATABASE_URL
: PostgreSQL connection string
-
Redis Settings:
QUEUE_PORT
andQUEUE_HOST
: Redis queue configurationCACHE_PORT
andCACHE_HOST
: Redis cache configuration
-
Network Settings:
APP_DOMAIN
: Your domain (e.g.,latitude.so
)APP_URL
: Full URL to your applicationGATEWAY_HOSTNAME
: API gateway hostnameGATEWAY_SSL
: Enable/disable SSL
-
Email Configuration:
MAILGUN_EMAIL_DOMAIN
: Email domain for sending emailsFROM_MAILER_EMAIL
: Sender email addressMAILGUN_MAILER_API_KEY
: Mailgun API key (optional)
-
Storage Configuration:
DRIVE_DISK
: Choose betweenlocal
ors3
for file storage- AWS S3 credentials (if using S3 storage)
-
Optional Features:
- Sentry integration for error tracking
- PostHog for analytics
Starting the Services
- Start all services using Docker Compose:
This will start the following services:
- API Gateway (accessible via
gateway.latitude.localhost
) - Background workers
- Migrations daemon that will run on startup and automatically apply database migrations
- PostgreSQL database on port 5432
- Redis on port 6379
- Traefik (reverse proxy) on port 80
- Web application (accessible via
app.latitude.localhost
) - WebSocket server (accessible via
ws.latitude.localhost
)
Service URLs
Once running, you can access:
- Main application:
http://app.latitude.localhost
- API Gateway:
http://gateway.latitude.localhost
- WebSocket server:
http://ws.latitude.localhost
- Traefik dashboard:
http://localhost:8090
Monitoring
You can monitor the services using standard Docker commands:
Important Notes
-
The services use Traefik as a reverse proxy, which automatically handles routing and service discovery.
-
The database data is persisted using a Docker volume mounted at
./docker/pgdata
. -
If you’re using local file storage, note that it requires additional configuration for multi-container setups, and S3 is recommended for production environments.
-
Make sure docker/init-db.sh has execution permissions or otherwise the database container will not start appropiately.
-
For a more robust production environment, make sure to:
- Set strong passwords in your
.env
file - Configure proper SSL certificates
- Use appropriate storage configuration (S3 recommended)
- Set up proper monitoring and logging
- We recommend using a container orchestration tool like k8s and handle env variables at runtime
- Set strong passwords in your
Public Docker Images
If you wanna set up your own docker environment, we provide public Docker images for each service in GitHub Container Registry.
To use the public images, you can pull them using the following commands. E.g: