typesense/docker-compose.yml

36 lines
1.6 KiB
YAML

# typesense-project/docker-compose.yml
version: '3.8'
services:
typesense:
image: typesense/typesense:${TYPESENSE_VERSION:-latest} # Uses TYPESENSE_VERSION from .env, defaults to latest
container_name: typesense_server
restart: unless-stopped
ports:
- "8108:8108" # Expose Typesense API port
volumes:
- ./typesense-data:/data # Persist Typesense data on the host machine
# The /data directory inside the container is where Typesense stores its data
environment:
# Pass the API key from the .env file to the container
# The Typesense container will pick this up via the --api-key command-line argument
TYPESENSE_API_KEY_FILE: /etc/typesense/typesense-api-key # Path inside container
# If you prefer to pass it directly as an env var (less secure if env vars are logged):
TYPESENSE_API_KEY: ${TYPESENSE_ADMIN_API_KEY}
# Command to start Typesense
# It needs to know where the data directory is and what the API key is.
command: '--data-dir /data --api-key=${TYPESENSE_ADMIN_API_KEY} --enable-cors'
# The --enable-cors flag is useful for local development when your frontend
# (e.g., on localhost:3000 or localhost:8000) talks to Typesense on localhost:8108
# Optional: Healthcheck to ensure Typesense is ready
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8108/health"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s # Give it some time to start up initially
networks:
default: # Default network, services can reach each other by service name