> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usertour.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy with Docker

> Deploy Usertour on your own infrastructure using Docker

<Warning>
  **Development/Testing Environment**:\
  We strongly recommend using Docker Compose for development and testing environments. This provides a quick and easy setup with all dependencies included.

  **Production Environment**:\
  For production deployments, we do **not** recommend using Docker Compose with Redis and PostgreSQL included. Instead:

  * Deploy Redis and PostgreSQL using cloud services (AWS, Google Cloud, etc.) or build your own infrastructure with high availability
  * Deploy only the Usertour application using the published [Docker Hub](https://hub.docker.com/r/usertour/usertour/) image and configure Redis and PostgreSQL through environment variables
</Warning>

## Docker Deployment Guide

### Prerequisites

Before starting the deployment, make sure you have:

* Docker and Docker Compose installed
* Basic understanding of Docker concepts
* Access to a server or local machine where you want to deploy Usertour

### Installation Steps

1. **Install Docker and [Docker Compose](https://docs.docker.com/compose/install/)**

2. **Configure Environment Variables**

   Create a `.env` file or add environment variables to your `docker-compose.yml`. You can use [this example file](https://github.com/usertour/usertour/blob/main/.env.example) as a reference. For detailed environment variable documentation, see [Environment Variables](/open-source/env).

3. **Create Docker Compose Configuration**

   Choose one of the following deployment options:

   #### Option 1: Local Development Setup

   This configuration includes all dependencies (PostgreSQL and Redis) in Docker containers:

   ```yaml theme={null}
   services:
     app:
       build:
         context: .
         dockerfile: Dockerfile
       ports:
         - "8011:80"
       env_file:
         - .env
       depends_on:
         postgres:
           condition: service_healthy
         redis:
           condition: service_healthy
       restart: always

     postgres:
       image: postgres:15-alpine
       environment:
         - POSTGRES_USER=postgres
         - POSTGRES_PASSWORD=postgres
         - POSTGRES_DB=usertour
       volumes:
         - postgres_data:/var/lib/postgresql/data
       healthcheck:
         test: ['CMD-SHELL', 'pg_isready -U postgres']
         interval: 10s
         timeout: 5s
         retries: 3
         start_period: 10s
       restart: always

     redis:
       image: redis:alpine
       volumes:
         - redis_data:/data
       healthcheck:
         test: ['CMD', 'redis-cli', 'ping']
         interval: 10s
         timeout: 5s
         retries: 3
         start_period: 10s
       restart: always

   volumes:
     postgres_data:
     redis_data:
   ```

   For local development, make sure to set these environment variables in your `.env` file:

   ```env theme={null}
   # Redis Configuration
   REDIS_HOST=redis
   REDIS_PORT=6379
   REDIS_PASS=

   # PostgreSQL Configuration
   DATABASE_URL=postgresql://postgres:postgres@postgres:5432/usertour?schema=usertour&sslmode=prefer
   ```

   #### Option 2: Production Setup

   For production environments, you'll need to:

   1. Deploy Redis and PostgreSQL using cloud services (AWS, Google Cloud, etc.) or build your own infrastructure with high availability
   2. Update the `.env` file with your Redis and PostgreSQL configuration
   3. Use this simplified configuration:

   ```yaml theme={null}
   services:
     app:
       image: usertour/usertour:latest
       ports:
         - "8011:80"
       env_file:
         - .env
       restart: always
   ```

4. **Start Usertour**

   Run the following command in the directory containing your `docker-compose.yml`:

   ```bash theme={null}
   docker-compose -f docker-compose.yml up -d
   ```

   If you're using the latest version of Docker, use:

   ```bash theme={null}
   docker compose -f docker-compose.yml up -d
   ```

   This command will:

   * Initialize the database
   * Run database migrations
   * Start the Usertour application on port 8011

### Accessing Usertour

1. **Initial Access**
   * Navigate to `http://<your-server-ip>:8011` or your configured domain and port
   * Note: Usertour runs on HTTP by default. For HTTPS, you'll need to set up a reverse proxy

2. **Set up the first admin account**
   * Open the site in your browser
   * On a fresh self-hosted deployment, Usertour will guide you to create the first **System Admin** account
   * After setup, sign in with that account and open **System Admin** from the account menu

3. **Upgrading older deployments**
   * If you are upgrading from an older self-hosted version and do not yet have a **System Admin**, assign one manually before signing in
   * A PostgreSQL example is available in the [System Admin guide](/open-source/system-admin)
   * If you are running version `0.5.0` or earlier, the seeded bootstrap admin is still `lisa@simpson.com` with password `secret42`

### Next Steps

Review the [System Admin guide](/open-source/system-admin) to configure instance settings, authentication, subscription, users, and projects.

To enable content delivery and user tracking, install Usertour.js in your application. See the [Usertour.js installation guide](/open-source/usertourjs) for detailed instructions.
