Skip to content

Commit dec9f00

Browse files
committed
Refactor environment variable names for Tailscale integration: update configuration files, Dockerfile, and application code to use VITE_TAILSCALE_API_KEY and VITE_TAILSCALE_TAILNET; revise README and example environment file to reflect changes.
1 parent dd69fdd commit dec9f00

File tree

8 files changed

+86
-30
lines changed

8 files changed

+86
-30
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ EXPOSE 3000 3001
4949

5050
# Health check
5151
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
52-
CMD node -e "require('http').get('http://localhost:3001/api/v2/tailnet/' + process.env.TAILSCALE_TAILNET + '/devices', (res) => process.exit(res.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))"
52+
CMD node -e "require('http').get('http://localhost:3001/api/v2/tailnet/' + process.env.VITE_TAILSCALE_TAILNET + '/devices', (res) => process.exit(res.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))"
5353

5454
# Start both the API server and serve the built React app
5555
CMD ["dumb-init", "sh", "-c", "node server.js & npx serve -s dist -l 3000"]

README.md

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,31 @@ A modern, real-time web application for visualizing and analyzing network traffi
4343
## Quick Start
4444

4545
### Prerequisites
46-
- Node.js 18+ and npm 8+
4746
- Tailscale API key with appropriate permissions
4847
- Access to a Tailscale network
48+
- Docker (recommended) or Node.js 18+ and npm 8+
4949

50-
### Installation
50+
### Option 1: Using Docker (Recommended)
51+
52+
The fastest way to get started is using the pre-built Docker image:
53+
54+
```bash
55+
docker run -d \
56+
-p 3000:3000 \
57+
-p 3001:3001 \
58+
-e VITE_TAILSCALE_API_KEY=your-api-key \
59+
-e VITE_TAILSCALE_TAILNET=your-tailnet \
60+
--name tsflow \
61+
ghcr.io/rajsinghtech/tsflow:latest
62+
```
63+
64+
Then navigate to `http://localhost:3000` to start exploring your network!
65+
66+
### Option 2: Development Setup
5167

5268
1. **Clone the repository**
5369
```bash
54-
git clone https://github.com/your-username/tsflow.git
70+
git clone https://github.com/rajsinghtech/tsflow.git
5571
cd tsflow
5672
```
5773

@@ -67,8 +83,8 @@ A modern, real-time web application for visualizing and analyzing network traffi
6783

6884
Edit `.env` and add your Tailscale credentials:
6985
```env
70-
TAILSCALE_ACCESS_TOKEN=tskey-client-your-api-key-here
71-
TAILSCALE_TAILNET=your-tailnet-name
86+
VITE_TAILSCALE_API_KEY=tskey-client-your-api-key-here
87+
VITE_TAILSCALE_TAILNET=your-tailnet-name
7288
```
7389

7490
4. **Start the application**
@@ -86,10 +102,48 @@ A modern, real-time web application for visualizing and analyzing network traffi
86102

87103
## Docker Deployment
88104

105+
### Using Pre-built Images (Recommended)
106+
107+
Pre-built container images are automatically built and published to GitHub Container Registry:
108+
109+
```bash
110+
# Pull and run the latest image
111+
docker run -d \
112+
-p 3000:3000 \
113+
-p 3001:3001 \
114+
-e VITE_TAILSCALE_API_KEY=your-api-key \
115+
-e VITE_TAILSCALE_TAILNET=your-tailnet \
116+
--name tsflow \
117+
ghcr.io/rajsinghtech/tsflow:latest
118+
```
119+
120+
**Available tags:**
121+
- `latest` - Latest stable release from main branch
122+
- `<commit-sha>` - Specific commit builds
123+
- `<version>` - Tagged releases (when available)
124+
89125
### Using Docker Compose (Recommended)
90126

127+
Create a `docker-compose.yml` file:
128+
129+
```yaml
130+
version: '3.8'
131+
services:
132+
tsflow:
133+
image: ghcr.io/rajsinghtech/tsflow:latest
134+
ports:
135+
- "3000:3000"
136+
- "3001:3001"
137+
environment:
138+
- VITE_TAILSCALE_API_KEY=your-api-key
139+
- VITE_TAILSCALE_TAILNET=your-tailnet
140+
restart: unless-stopped
141+
```
142+
143+
Then start the application:
144+
91145
```bash
92-
# Build and start
146+
# Start the application
93147
docker-compose up -d
94148

95149
# View logs
@@ -99,7 +153,9 @@ docker-compose logs -f
99153
docker-compose down
100154
```
101155

102-
### Using Docker directly
156+
### Building from Source
157+
158+
If you prefer to build the image yourself:
103159

104160
```bash
105161
# Build image
@@ -109,8 +165,8 @@ docker build -t tsflow .
109165
docker run -d \
110166
-p 3000:3000 \
111167
-p 3001:3001 \
112-
-e TAILSCALE_ACCESS_TOKEN=your-api-key \
113-
-e TAILSCALE_TAILNET=your-tailnet \
168+
-e VITE_TAILSCALE_API_KEY=your-api-key \
169+
-e VITE_TAILSCALE_TAILNET=your-tailnet \
114170
--name tsflow \
115171
tsflow
116172
```
@@ -136,9 +192,9 @@ npm run preview
136192

137193
| Variable | Description | Default |
138194
|----------|-------------|---------|
139-
| `TAILSCALE_ACCESS_TOKEN` | Your Tailscale API key | Required |
140-
| `TAILSCALE_TAILNET` | Your tailnet name | Required |
141-
| `PROXY_TAILSCALE_BASE_URL` | API base URL | `http://localhost:3001/api/v2` |
195+
| `VITE_TAILSCALE_API_KEY` | Your Tailscale API key | Required |
196+
| `VITE_TAILSCALE_TAILNET` | Your tailnet name | Required |
197+
| `VITE_TAILSCALE_BASE_URL` | API base URL | `http://localhost:3001/api/v2` |
142198

143199
## Usage
144200

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ services:
77
- "3000:3000" # Frontend
88
- "3001:3001" # API proxy
99
environment:
10-
- TAILSCALE_ACCESS_TOKEN=${TAILSCALE_ACCESS_TOKEN}
11-
- TAILSCALE_TAILNET=${TAILSCALE_TAILNET}
12-
- PROXY_TAILSCALE_BASE_URL=http://localhost:3001/api/v2
10+
- VITE_TAILSCALE_API_KEY=${VITE_TAILSCALE_API_KEY}
11+
- VITE_TAILSCALE_TAILNET=${VITE_TAILSCALE_TAILNET}
12+
- VITE_TAILSCALE_BASE_URL=http://localhost:3001/api/v2
1313
- NODE_ENV=production
1414
env_file:
1515
- .env

env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Tailscale API Configuration
22
# Get your API key from: https://login.tailscale.com/admin/settings/keys
3-
TAILSCALE_ACCESS_TOKEN=tskey-client-your-api-key-here
3+
VITE_TAILSCALE_API_KEY=tskey-client-your-api-key-here
44

55
# Your Tailnet name (e.g., example.com or example.ts.net)
6-
TAILSCALE_TAILNET=your-tailnet-name
6+
VITE_TAILSCALE_TAILNET=your-tailnet-name
77

88
# API Base URL (usually doesn't need to change)
9-
PROXY_TAILSCALE_BASE_URL=https://api.tailscale.com/api/v2
9+
VITE_TAILSCALE_BASE_URL=https://api.tailscale.com/api/v2

server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ app.use(express.json());
1818
// Proxy endpoint for Tailscale API
1919
app.use('/api/v2', async (req, res) => {
2020
try {
21-
const apiKey = process.env.TAILSCALE_ACCESS_TOKEN;
22-
const tailnet = process.env.TAILSCALE_TAILNET;
21+
const apiKey = process.env.VITE_TAILSCALE_API_KEY;
22+
const tailnet = process.env.VITE_TAILSCALE_TAILNET;
2323

2424
if (!apiKey || !tailnet) {
2525
return res.status(500).json({

src/lib/api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ const loadConfig = (): TailscaleConfig => {
1212
const savedTailnet = localStorage.getItem('tsflow-tailnet')
1313

1414
// Fallback to environment variables
15-
const envApiKey = import.meta.env.TAILSCALE_ACCESS_TOKEN
16-
const envTailnet = import.meta.env.TAILSCALE_TAILNET
17-
const envBaseUrl = import.meta.env.PROXY_TAILSCALE_BASE_URL
15+
const envApiKey = import.meta.env.VITE_TAILSCALE_API_KEY
16+
const envTailnet = import.meta.env.VITE_TAILSCALE_TAILNET
17+
const envBaseUrl = import.meta.env.VITE_TAILSCALE_BASE_URL
1818

1919
return {
2020
apiKey: savedApiKey || envApiKey || '',

src/pages/Settings.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export default function Settings() {
3030
const savedTailnet = localStorage.getItem('tsflow-tailnet')
3131

3232
// Load from environment variables as fallback
33-
const envApiKey = import.meta.env.TAILSCALE_ACCESS_TOKEN
34-
const envTailnet = import.meta.env.TAILSCALE_TAILNET
33+
const envApiKey = import.meta.env.VITE_TAILSCALE_API_KEY
34+
const envTailnet = import.meta.env.VITE_TAILSCALE_TAILNET
3535

3636
// Set API key (localStorage first, then env)
3737
const finalApiKey = savedApiKey || envApiKey || ''
@@ -311,7 +311,7 @@ export default function Settings() {
311311
<p><strong>API Key:</strong> Generate from Tailscale Admin Console → Settings → Keys</p>
312312
<p><strong>Permissions:</strong> API key needs "Devices" read access at minimum</p>
313313
<p><strong>Tailnet:</strong> Found in your Tailscale admin console URL or settings</p>
314-
<p><strong>Environment Variables:</strong> Set TAILSCALE_ACCESS_TOKEN and TAILSCALE_TAILNET</p>
314+
<p><strong>Environment Variables:</strong> Set VITE_TAILSCALE_API_KEY and VITE_TAILSCALE_TAILNET</p>
315315
<p><strong>Auto-loading:</strong> App loads env vars on startup if no saved config exists</p>
316316
<p><strong>Issues:</strong> Check your API key permissions and tailnet name</p>
317317
</div>

src/vite-env.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/// <reference types="vite/client" />
22

33
interface ImportMetaEnv {
4-
readonly TAILSCALE_ACCESS_TOKEN: string
5-
readonly TAILSCALE_TAILNET: string
6-
readonly PROXY_TAILSCALE_BASE_URL: string
4+
readonly VITE_TAILSCALE_API_KEY: string
5+
readonly VITE_TAILSCALE_TAILNET: string
6+
readonly VITE_TAILSCALE_BASE_URL: string
77
}
88

99
interface ImportMeta {

0 commit comments

Comments
 (0)