Skip to content

Deploying an InfluxDB App

Introduction

InfluxDB is a high-performance time-series database with an HTTP API and UI. Deploying InfluxDB with a Dockerfile on Klutch.sh gives you reproducible builds, managed secrets, and durable storage for metrics—all from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, and best practices for secure, scalable observability data.


Prerequisites

  • A Klutch.sh account (create one)
  • A GitHub repository containing your InfluxDB configuration (GitHub is the only supported git source)
  • Docker familiarity and basic knowledge of InfluxDB buckets, orgs, and tokens
  • Adequate persistent storage for time-series data and WAL

For platform basics, see the Quick Start.


Architecture and ports

  • InfluxDB serves HTTP on port 8086 for both API and UI.
  • On Klutch.sh, choose HTTP traffic and set the internal container port to 8086.
  • If you expose additional TCP services (rare for InfluxDB), run them as separate Klutch.sh TCP apps; external TCP port is 8000.
  • Persistent storage is required for /var/lib/influxdb2.

Repository layout

influxdb/
├── config/ # Optional custom configs or init scripts
├── Dockerfile # Must be at repo root for auto-detection
├── README.md
└── .env.example # Template only; no secrets

Keep secrets out of Git; store them in Klutch.sh environment variables.


Installation (local) and starter commands

Quick local run for testing:

Terminal window
docker run --rm -p 8086:8086 \
-v $(pwd)/data:/var/lib/influxdb2 \
-e DOCKER_INFLUXDB_INIT_MODE=setup \
-e DOCKER_INFLUXDB_INIT_USERNAME=admin \
-e DOCKER_INFLUXDB_INIT_PASSWORD=StrongPass123! \
-e DOCKER_INFLUXDB_INIT_ORG=example-org \
-e DOCKER_INFLUXDB_INIT_BUCKET=example-bucket \
influxdb:2

Optional start.sh for portability and Nixpacks fallback:

#!/usr/bin/env bash
set -euo pipefail
exec influxd run

Make it executable with chmod +x start.sh.


Dockerfile for InfluxDB (production-ready)

Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):

FROM influxdb:2.7
WORKDIR /app
# Optional: Copy custom configuration or scripts
COPY config /etc/influxdb2
EXPOSE 8086
CMD ["influxd", "run", "--engine-path", "/var/lib/influxdb2"]

Notes:

  • Pin the image tag for reproducible builds.
  • If you mount TLS certs, place them via a volume and reference in your config.

Environment variables (Klutch.sh)

Set these in the Klutch.sh app settings (Secrets tab) before deploying:

  • DOCKER_INFLUXDB_INIT_MODE=setup
  • DOCKER_INFLUXDB_INIT_USERNAME=admin
  • DOCKER_INFLUXDB_INIT_PASSWORD=<strong-password>
  • DOCKER_INFLUXDB_INIT_ORG=example-org
  • DOCKER_INFLUXDB_INIT_BUCKET=example-bucket
  • DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=<admin-token>
  • INFLUXD_HTTP_BIND_ADDRESS=:8086

If you deploy without the Dockerfile and need Nixpacks overrides:

  • NIXPACKS_BUILD_CMD=go build -o influxd ./cmd/influxd
  • NIXPACKS_START_CMD=./influxd run --engine-path /var/lib/influxdb2
  • NIXPACKS_GO_VERSION=1.21

These keep InfluxDB compatible with Nixpacks defaults when a Dockerfile is absent.


Attach persistent volumes

In Klutch.sh storage settings, add mount paths and sizes (no names required):

  • /var/lib/influxdb2 — required for data, WAL, and metadata.
  • /etc/influxdb2 — optional if you want to persist custom configuration.

Ensure these paths are writable inside the container.


Deploy InfluxDB on Klutch.sh (Dockerfile workflow)

  1. Push your repository (with the Dockerfile at the root) to GitHub.
  2. Open klutch.sh/app, create a project, and add an app.
  3. Connect the GitHub repository; Klutch.sh automatically detects the Dockerfile.
  4. Choose HTTP traffic for InfluxDB.
  5. Set the internal port to 8086.
  6. Add the environment variables above (setup credentials, org/bucket, admin token, and any NIXPACKS_* overrides if you temporarily deploy without the Dockerfile).
  7. Attach persistent volumes for /var/lib/influxdb2 (and /etc/influxdb2 if desired), choosing sizes that fit your retention policy.
  8. Deploy. Your InfluxDB instance will be reachable at https://example-app.klutch.sh; add a custom domain if needed.

For companion services like Telegraf or Redis, create separate apps and connect via service URLs; TCP apps expose externally on port 8000.


Health checks and production tips

  • Use the /health endpoint for monitoring.
  • Enforce HTTPS at the edge; forward HTTP to port 8086 internally.
  • Rotate admin tokens and passwords regularly; keep them only in Klutch.sh secrets.
  • Monitor disk usage on /var/lib/influxdb2 and resize before it fills.
  • Pin image and Go versions to avoid unexpected upgrades.

InfluxDB on Klutch.sh combines reproducible Docker builds with managed secrets, durable volumes, and flexible HTTP/TCP routing. With the Dockerfile at the repo root and ports set to 8086 for the app (8000 externally for TCP companions), you can run a reliable time-series database without extra YAML or workflow overhead.