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

# Deploy InfraAudit Using Docker Compose Step by Step

> Run InfraAudit locally or on a server using Docker Compose. Starts the API, database, Redis, and frontend in four containers with one command.

Docker Compose is the fastest way to get InfraAudit running. A single `docker compose up` command starts the Go API, Postgres database, Redis cache, and the React frontend — no Kubernetes cluster required.

<Note>
  Complete the [Prerequisites](/self-hosting/prerequisites) first. You need a Supabase project and Docker Compose v2 before starting.
</Note>

## Step 1: Clone the repository

```bash theme={null}
git clone https://github.com/pratik-mahalle/infraudit-go.git
cd infraudit-go
```

## Step 2: Create your `.env` file

Copy the example environment file:

```bash theme={null}
cp .env.example .env
```

Open `.env` and fill in your values. The template below shows every variable you need for a working deployment:

```env theme={null}
# Supabase — required (see /self-hosting/prerequisites)
SUPABASE_URL=https://xxxxxxxxxxxxxx.supabase.co
SUPABASE_JWT_SECRET=your-jwt-secret-here
SUPABASE_ANON_KEY=eyJhbGciOi...
SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOi...

# Server
SERVER_PORT=8080
FRONTEND_URL=http://localhost:5173
ENVIRONMENT=development

# Database — provisioned automatically by Docker Compose
DB_DRIVER=postgres
DB_HOST=postgres
DB_PORT=5432
DB_NAME=infraudit
DB_USER=infraudit
DB_PASSWORD=change-me-production-password
DB_SSLMODE=disable

# Credential encryption — generate with: openssl rand -hex 32
ENCRYPTION_KEY=change-me-32-byte-random-string-here

# Optional: AI recommendations
GEMINI_API_KEY=

# Optional: Slack notifications
SLACK_WEBHOOK_URL=
```

<Warning>
  You must change two values before any real deployment:

  * **`ENCRYPTION_KEY`** — encrypts all cloud provider credentials stored in Postgres. Generate a secure value with `openssl rand -hex 32`. Never use the placeholder.
  * **`DB_PASSWORD`** — the default is publicly known. Change it before exposing the deployment to any network.
</Warning>

For the full list of configurable variables, see the [Configuration reference](/self-hosting/configuration).

## Step 3: Start the stack

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

This starts four containers:

| Container  | Port | Purpose               |
| ---------- | ---- | --------------------- |
| `api`      | 8080 | InfraAudit Go backend |
| `postgres` | 5432 | Primary database      |
| `redis`    | 6379 | Cache layer           |
| `frontend` | 5173 | React web UI          |

Watch the API logs until it reports ready:

```bash theme={null}
docker compose logs -f api
```

You should see:

```
api_1  | InfraAudit API starting on :8080
api_1  | Database connected (postgres)
api_1  | Redis connected
api_1  | Supabase auth configured
```

If the API exits immediately with `SUPABASE_JWT_SECRET is required`, the Supabase values in `.env` are missing or incorrect.

## Step 4: Verify the deployment

Run the health checks:

```bash theme={null}
curl http://localhost:8080/healthz
# {"status":"ok"}

curl http://localhost:8080/readyz
# {"status":"ready","database":"ok","redis":"ok"}
```

Then open `http://localhost:5173` in your browser and sign up.

## Optional: enable monitoring

Add Prometheus and Grafana with the monitoring profile:

```bash theme={null}
docker compose --profile monitoring up -d
```

| Container    | Port | Purpose         |
| ------------ | ---- | --------------- |
| `prometheus` | 9090 | Metrics scraper |
| `grafana`    | 3000 | Dashboard UI    |

Grafana starts with a pre-built InfraAudit dashboard. Log in with `admin` / `admin` and change the password on first login.

## Managing the stack

<CodeGroup>
  ```bash Stop containers theme={null}
  # Stop without removing volumes (data is preserved)
  docker compose down
  ```

  ```bash Stop and wipe data theme={null}
  # Stop and remove all volumes — this deletes your database
  docker compose down -v
  ```

  ```bash Restart a single container theme={null}
  docker compose restart api
  ```

  ```bash View logs theme={null}
  docker compose logs -f api
  ```
</CodeGroup>

## Updating to a new version

Pull the latest images and restart:

```bash theme={null}
docker compose pull
docker compose up -d
```

The API runs any pending database migrations automatically on startup. See [Upgrades](/self-hosting/upgrades) for details on what to check before pulling a new version.

## Production considerations

Before exposing your deployment to the internet:

* Place a reverse proxy (nginx, Caddy) in front of port 8080 to terminate TLS.
* Set `ENVIRONMENT=production` — this disables the Swagger UI and debug endpoints.
* Set `ALLOWED_ORIGINS` to your frontend domain instead of the default `*`.
* Store secrets in environment variables or a secrets manager rather than the `.env` file.
* Read [Secrets and encryption](/self-hosting/secrets-and-encryption) before going live.
