diff --git a/.env b/.env new file mode 100644 index 0000000..8418513 --- /dev/null +++ b/.env @@ -0,0 +1,7 @@ +# typesense-project/.env + +# Choose a strong, random string for your Admin API Key +TYPESENSE_ADMIN_API_KEY=imdiowenxodjioqwenlj + +# You can also specify the Typesense version here if you want to pin it +TYPESENSE_VERSION=28.0 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..27937b9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,36 @@ +# 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 \ No newline at end of file