Skip to content

Commit 4df30fe

Browse files
authored
Add initial configuration files for Kavita with Tailscale sidecar (#158)
* Add initial configuration files for Kavita with Tailscale sidecar * Fix formatting of file verification list in README
1 parent 24b72dd commit 4df30fe

File tree

4 files changed

+110
-0
lines changed

4 files changed

+110
-0
lines changed

services/kavita/.env

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#version=1.0
2+
#url=https://github.com/2Tiny2Scale/tailscale-docker-sidecar-configs
3+
#COMPOSE_PROJECT_NAME= // only use in multiple deployments on the same infra
4+
SERVICE=kavita
5+
IMAGE_URL=jvmilazz0/kavita:latest
6+
SERVICEPORT=5000
7+
TS_AUTHKEY=
8+
DNS_SERVER=9.9.9.9

services/kavita/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Kavita with Tailscale Sidecar Configuration
2+
3+
This Docker Compose configuration sets up [Kavita](https://github.com/Kareadita/Kavita) with Tailscale as a sidecar container to securely serve your comics, manga, and ebooks over a private Tailscale network. By running Tailscale as a sidecar, you restrict access to your Kavita instance to devices authenticated on your Tailnet, avoiding public exposure.
4+
5+
## Kavita
6+
7+
[Kavita](https://github.com/Kareadita/Kavita) is an open-source, self-hosted digital library manager optimized for comics, manga, and ebooks. It provides a modern web UI for browsing collections, reading in-browser, managing metadata, and syncing reading progress across devices. Kavita supports multiple users, libraries, and common archive formats.
8+
9+
## Key Features
10+
11+
* **Library Management** – Organize comics, manga, and ebooks with metadata, tags, and collections.
12+
* **In-Browser Reader** – Read content directly in the browser with smooth navigation and zoom controls.
13+
* **Multi-User Support** – Create accounts with individualized reading progress and permissions.
14+
* **Archive Support** – Handles CBZ, CBR, EPUB, and other common formats.
15+
* **Self-Hosted & Private** – Keep your media on your infrastructure.
16+
* **Private by Default with Tailscale** – Access Kavita only from devices on your Tailnet.
17+
18+
## Configuration Overview
19+
20+
In this setup, the `tailscale-kavita` service runs the Tailscale client to join your private mesh network. The `kavita` service is configured with `network_mode: service:tailscale-kavita`, so all network traffic for Kavita is routed through the Tailscale container. This ensures the web UI and API are reachable only via your Tailscale network (or locally), adding an extra layer of privacy and security to your self-hosted library.
21+
22+
## Files to check
23+
24+
Please verify the following files and variables before deploying:
25+
26+
* `.env` — define SERVICE, IMAGE_URL, SERVICEPORT, TS_AUTHKEY, etc.
27+
* `./config/serve.json` — optional Tailscale Serve configuration if you want to expose specific ports within the Tailnet.
28+
* `./kavita-data` — ensure persistent volumes for libraries and config are correctly mapped.

services/kavita/config/serve.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"TCP": {
3+
"443": {
4+
"HTTPS": true
5+
}
6+
},
7+
"Web": {
8+
"${TS_CERT_DOMAIN}:443": {
9+
"Handlers": {
10+
"/": {
11+
"Proxy": "http://127.0.0.1:5000"
12+
}
13+
}
14+
}
15+
}
16+
}

services/kavita/docker-compose.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
services:
2+
# Make sure you have updated/checked the .env file with the correct variables.
3+
# All the ${ xx } need to be defined there.
4+
# Tailscale Sidecar Configuration
5+
tailscale:
6+
image: tailscale/tailscale:latest # Image to be used
7+
container_name: tailscale-${SERVICE} # Name for local container management
8+
hostname: ${SERVICE} # Name used within your Tailscale environment
9+
environment:
10+
- TS_AUTHKEY=${TS_AUTHKEY}
11+
- TS_STATE_DIR=/var/lib/tailscale
12+
- TS_SERVE_CONFIG=/config/serve.json # Tailscale Serve configuration to expose the web interface on your local Tailnet - remove this line if not required
13+
- TS_USERSPACE=false
14+
- TS_ENABLE_HEALTH_CHECK=true # Enable healthcheck endpoint: "/healthz"
15+
- TS_LOCAL_ADDR_PORT=127.0.0.1:41234 # The <addr>:<port> for the healthz endpoint
16+
#- TS_ACCEPT_DNS=true # Uncomment when using MagicDNS
17+
volumes:
18+
- ./config:/config # Config folder used to store Tailscale files - you may need to change the path
19+
- ./ts/state:/var/lib/tailscale # Tailscale requirement - you may need to change the path
20+
devices:
21+
- /dev/net/tun:/dev/net/tun # Network configuration for Tailscale to work
22+
cap_add:
23+
- net_admin # Tailscale requirement
24+
#ports:
25+
# - 0.0.0.0:${SERVICEPORT}:${SERVICEPORT} # Binding port ${SERVICE}PORT to the local network - may be removed if only exposure to your Tailnet is required
26+
# If any DNS issues arise, use your preferred DNS provider by uncommenting the config below
27+
#dns:
28+
# - ${DNS_SERVER}
29+
healthcheck:
30+
test: ["CMD", "wget", "--spider", "-q", "http://127.0.0.1:41234/healthz"] # Check Tailscale has a Tailnet IP and is operational
31+
interval: 1m # How often to perform the check
32+
timeout: 10s # Time to wait for the check to succeed
33+
retries: 3 # Number of retries before marking as unhealthy
34+
start_period: 10s # Time to wait before starting health checks
35+
restart: always
36+
37+
# ${SERVICE}
38+
application:
39+
image: ${IMAGE_URL} # Image to be used
40+
network_mode: service:tailscale # Sidecar configuration to route ${SERVICE} through Tailscale
41+
container_name: app-${SERVICE} # Name for local container management
42+
environment:
43+
- TZ=Europe/Amsterdam
44+
volumes:
45+
- ./${SERVICE}-data/manga:/manga
46+
- ./${SERVICE}-data/comics:/comics
47+
- ./${SERVICE}-data/books:/books
48+
- ./${SERVICE}-data/config:/kavita/config
49+
depends_on:
50+
tailscale:
51+
condition: service_healthy
52+
healthcheck:
53+
test: ["CMD", "pgrep", "-f", "${SERVICE}"] # Check if ${SERVICE} process is running
54+
interval: 1m # How often to perform the check
55+
timeout: 10s # Time to wait for the check to succeed
56+
retries: 3 # Number of retries before marking as unhealthy
57+
start_period: 30s # Time to wait before starting health checks
58+
restart: always

0 commit comments

Comments
 (0)