| title | Local - Docker Compose |
|---|
This guide walks you through setting up Langtail for local development using Docker Compose.
Note: This setup is for local development only. It is not recommended for production due to the use of default secrets and non-persistent database. For production, follow the Kubernetes Helm Chart guide.
- Docker and Docker Compose installed.
- Basic knowledge of Docker Compose commands.
Below is the Docker Compose configuration for running Langtail locally:
services:
db:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: langtail
MYSQL_USER: admin
MYSQL_PASSWORD: admin
ports:
- "3306:3306"
volumes:
- mysql-data:/var/lib/mysql # Persists data across container restarts
wait-for-db:
image: atkrad/wait4x
depends_on:
db:
condition: service_started
command: tcp db:3306 -t 30s -i 250ms
init-db:
platform: linux/amd64
image: langtail/langtail-db-migrations:latest
environment:
DATABASE_URL: "mysql://admin:admin@db:3306/langtail"
depends_on:
wait-for-db:
condition: service_completed_successfully
app:
platform: linux/amd64
image: langtail/langtail:latest
environment:
# Email login (remove if not needed)
SMTP_URL: "smtp://user:password@smtp.example.com:587"
EMAIL_FROM: "default@example.com"
EMAIL_VERIFICATION_SECRET: "default-email-verification-secret"
# JWT keys (use default or generate your own)
JWT_PRIVATE: '{"key_ops":["sign"],"kty": "EC","d": "bSsPE9H0IiKvxxZA6zPxjUpSLqa0bIDlluPxnTNnt88","use": "sig","crv": "P-256","x": "IavsPecpkyukuGxL6qcS6a-TG_yE9Rv4O_MaM8moUI0","y": "S9NhGgdxLrZHYgvrcT1xEMW76rM_x2C64h_y2oUGnfo","alg": "ES256"}'
JWT_PUBLIC: '{"key_ops":["verify"],"kty": "EC","use": "sig","crv": "P-256","x": "IavsPecpkyukuGxL6qcS6a-TG_yE9Rv4O_MaM8moUI0","y": "S9NhGgdxLrZHYgvrcT1xEMW76rM_x2C64h_y2oUGnfo","alg": "ES256"}'
JWT_SIGNING_KEY: '{"kty": "oct","use": "sig","k": "vRCzGRHUGztzfvB-TSmNmcBHiC2ccz92M0RDJNkmwZjmFHsD_xlfHGD_3qewcO0p23s_BJIQkW92pRW4zNVPnO66jY3-ZZ7dIbt4x3ETh6-9TJ5X_B9Rb9e9ZNraH3TSKidW0Q6IvZq01qRSBiuhIddeC20HdFdUe-M-yGygie3EvsxXA3tL__o9pb25LHovsqZDwAi46TpovwHF5lS9K_a79-a9HLhPLvqbclSbhcC0mDwFiHaRGyB-xKiOpgpmdbdf2d1sdUnx8i8sA3sYS5Lo4gyhk2r_U2a8l9oU2s44erp-i3klGsVYuE82JNOeB9B7-hYuTwckvXLm75G0Ng"}'
# Authentication settings
AUTH_SECRET: "7AdqG566X2lX2klWVbgjlLZVjgxLve2a/NVRHCs0PnI=" # Generate using guide below
AUTH_URL: "http://localhost:3000"
# Database
DATABASE_URL: "mysql://admin:admin@db:3306/langtail"
PRISMA_FIELD_ENCRYPTION_KEY: "k1.aesgcm256.Yf2B9VlwQGmRSOzppSxEgnAgxCnk3ucvbwcqul17f_g=" # Generate using guide below
# Misc configurations (adjust if needed)
SENTRY_ENABLED: "false"
IMAGES_AWS_SECRET_ACCESS_KEY: "default-aws-secret-access-key" # Key to S3 compatible image storage
# Social login IDs (remove if you don't need them)
GITHUB_ID: "default-github-id"
GITHUB_SECRET: "default-github-secret"
GOOGLE_ID: "default-google-id"
GOOGLE_SECRET: "default-google-secret"
ports:
- 3000:3000
depends_on:
init-db:
condition: service_completed_successfully
volumes:
mysql-data:- db: Runs a MySQL 8.0 database with credentials for local use.
- wait-for-db: Ensures the database is ready before starting other services.
- init-db: Initializes the database by running migrations after the database is ready.
- app: The main Langtail application, which depends on the database and migrations.
While the default secrets are fine for local development, it is recommended to generate your own if desired. Here are the steps:
Run the following command to generate a new AUTH_SECRET:
$ openssl rand -base64 32To generate new JWT keys:
- Go to https://mkjwk.org/.
- Select EC as the key type and P-256 as the curve.
- Copy the public and private keys and replace them in your
docker-compose.ymlunderJWT_PRIVATEandJWT_PUBLIC.
To generate a new signing key:
- Go to https://mkjwk.org/.
- Select oct as the key type and Signature as the key use.
- Copy the generated key and replace the
JWT_SIGNING_KEYin yourdocker-compose.yml.
If you want to test sending emails (e.g., for user sign-up verification), you will need to set up an SMTP server. For local development, you can use a free service like Ethereal Email.
- Sign up for a free Ethereal Email account.
- Copy the SMTP credentials (host, port, username, password).
- Update the
SMTP_URLin yourdocker-compose.ymlwith the following format:
SMTP_URL="smtp://username:password@smtp.ethereal.email:587"Langtail supports social login via Google and GitHub. To enable this feature, you need to obtain OAuth credentials from Google and GitHub and set the corresponding environment variables.
- Follow the instructions at NextAuth.js - Google Provider to create a Google OAuth application.
- Obtain your Google Client ID and Google Client Secret.
- Update your
docker-compose.yml:
environment:
GOOGLE_ID: "your-google-client-id"
GOOGLE_SECRET: "your-google-client-secret"- Follow the instructions at NextAuth.js - GitHub Provider to create a GitHub OAuth application.
- Obtain your GitHub Client ID and GitHub Client Secret.
- Update your
docker-compose.yml:
environment:
GITHUB_ID: "your-github-client-id"
GITHUB_SECRET: "your-github-client-secret"Note: Ensure that your OAuth application's redirect URIs are set correctly to
http://localhost:3000/api/auth/callback/googlefor Google andhttp://localhost:3000/api/auth/callback/githubfor GitHub.
- Save the
docker-compose.ymlfile in your project root. - Run the following command to start the services:
docker-compose up- Once all services are up, you can access the app at http://localhost:3000.