Skip to content

Commit 4d48e1b

Browse files
committed
Refactor environment variable names for Tailscale integration: replace VITE_TAILSCALE_API_KEY and VITE_TAILSCALE_TAILNET with TAILSCALE_ACCESS_TOKEN and TAILSCALE_TAILNET across configuration files, Dockerfile, and application code; update README and example environment file accordingly.
1 parent 6aab5ed commit 4d48e1b

File tree

9 files changed

+62
-64
lines changed

9 files changed

+62
-64
lines changed

.github/workflows/build.yml

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
env:
1212
REGISTRY: ghcr.io
1313
IMAGE_NAME: ${{ github.repository }}
14+
NODE_VERSION: '18'
1415

1516
jobs:
1617
build:
@@ -25,34 +26,29 @@ jobs:
2526
- name: Checkout repository
2627
uses: actions/checkout@v4
2728

28-
- name: Set up Go
29-
uses: actions/setup-go@v4
29+
- name: Set up Node.js
30+
uses: actions/setup-node@v4
3031
with:
31-
go-version: '1.21'
32-
cache: true
32+
node-version: ${{ env.NODE_VERSION }}
33+
cache: 'npm'
3334

34-
- name: Download dependencies
35-
run: go mod download
35+
- name: Install dependencies
36+
run: npm ci
3637

37-
- name: Run tests
38-
run: |
39-
go test -v ./...
40-
go vet ./...
38+
- name: Run linting
39+
run: npm run lint
4140

42-
- name: Build binary
43-
run: |
44-
go build -ldflags="-w -s" -o tsflow .
45-
chmod +x tsflow
41+
- name: Run type checking
42+
run: npm run type-check
43+
44+
- name: Build application
45+
run: npm run build
4646

47-
- name: Build multi-platform binaries
47+
- name: Create build archive
4848
if: github.event_name == 'release'
4949
run: |
50-
GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o tsflow-linux-amd64 .
51-
GOOS=linux GOARCH=arm64 go build -ldflags="-w -s" -o tsflow-linux-arm64 .
52-
GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o tsflow-darwin-amd64 .
53-
GOOS=darwin GOARCH=arm64 go build -ldflags="-w -s" -o tsflow-darwin-arm64 .
54-
GOOS=windows GOARCH=amd64 go build -ldflags="-w -s" -o tsflow-windows-amd64.exe .
55-
chmod +x tsflow-*
50+
tar -czf tsflow-build.tar.gz dist/
51+
sha256sum tsflow-build.tar.gz > checksums.txt
5652
5753
- name: Set up Docker Buildx
5854
if: github.event_name != 'pull_request'
@@ -84,43 +80,45 @@ jobs:
8480
labels: |
8581
org.opencontainers.image.source=${{ github.event.repository.html_url }}
8682
org.opencontainers.image.revision=${{ github.sha }}
83+
org.opencontainers.image.title=TSFlow
84+
org.opencontainers.image.description=Tailscale Network Flow Visualizer
8785
cache-from: type=gha
8886
cache-to: type=gha,mode=max
8987

90-
91-
92-
- name: Create release archives
93-
if: github.event_name == 'release'
94-
run: |
95-
tar -czf tsflow-linux-amd64.tar.gz tsflow-linux-amd64
96-
tar -czf tsflow-linux-arm64.tar.gz tsflow-linux-arm64
97-
tar -czf tsflow-darwin-amd64.tar.gz tsflow-darwin-amd64
98-
tar -czf tsflow-darwin-arm64.tar.gz tsflow-darwin-arm64
99-
zip tsflow-windows-amd64.zip tsflow-windows-amd64.exe
100-
sha256sum *.tar.gz *.zip > checksums.txt
101-
10288
- name: Upload release assets
10389
if: github.event_name == 'release'
10490
uses: softprops/action-gh-release@v1
10591
with:
10692
files: |
107-
*.tar.gz
108-
*.zip
93+
tsflow-build.tar.gz
10994
checksums.txt
11095
body: |
11196
## TSFlow ${{ github.ref_name }}
11297
98+
A modern web application for visualizing and analyzing network traffic flows within Tailscale networks.
99+
113100
### Docker Installation
114101
```bash
115102
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}:latest
116-
docker run -p 8080:8080 \
117-
-e TAILSCALE_ACCESS_TOKEN="your-token" \
103+
docker run -p 3000:3000 -p 3001:3001 \
118104
-e TAILSCALE_TAILNET="your-tailnet" \
105+
-e TAILSCALE_ACCESS_TOKEN="your-access-token" \
119106
${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}:latest
120107
```
121108
122-
### Binary Installation
123-
Download the appropriate binary for your platform from the assets below.
109+
### Manual Installation
110+
1. Download the build archive from the assets below
111+
2. Extract: `tar -xzf tsflow-build.tar.gz`
112+
3. Serve the `dist/` directory with any static file server
113+
4. Set up the API server separately using `server.js`
114+
115+
### Development Setup
116+
```bash
117+
git clone https://github.com/${{ github.repository }}.git
118+
cd tsflow
119+
npm install
120+
npm run dev:full
121+
```
124122
draft: false
125123
prerelease: false
126124
env:

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.VITE_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.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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ A modern, real-time web application for visualizing and analyzing network traffi
6767

6868
Edit `.env` and add your Tailscale credentials:
6969
```env
70-
VITE_TAILSCALE_API_KEY=tskey-client-your-api-key-here
71-
VITE_TAILSCALE_TAILNET=your-tailnet-name
70+
TAILSCALE_ACCESS_TOKEN=tskey-client-your-api-key-here
71+
TAILSCALE_TAILNET=your-tailnet-name
7272
```
7373

7474
4. **Start the application**
@@ -109,8 +109,8 @@ docker build -t tsflow .
109109
docker run -d \
110110
-p 3000:3000 \
111111
-p 3001:3001 \
112-
-e VITE_TAILSCALE_API_KEY=your-api-key \
113-
-e VITE_TAILSCALE_TAILNET=your-tailnet \
112+
-e TAILSCALE_ACCESS_TOKEN=your-api-key \
113+
-e TAILSCALE_TAILNET=your-tailnet \
114114
--name tsflow \
115115
tsflow
116116
```
@@ -136,9 +136,9 @@ npm run preview
136136

137137
| Variable | Description | Default |
138138
|----------|-------------|---------|
139-
| `VITE_TAILSCALE_API_KEY` | Your Tailscale API key | Required |
140-
| `VITE_TAILSCALE_TAILNET` | Your tailnet name | Required |
141-
| `VITE_TAILSCALE_BASE_URL` | API base URL | `http://localhost:3001/api/v2` |
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` |
142142

143143
## Usage
144144

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-
- 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
10+
- TAILSCALE_ACCESS_TOKEN=${TAILSCALE_ACCESS_TOKEN}
11+
- TAILSCALE_TAILNET=${TAILSCALE_TAILNET}
12+
- PROXY_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-
VITE_TAILSCALE_API_KEY=tskey-client-your-api-key-here
3+
TAILSCALE_ACCESS_TOKEN=tskey-client-your-api-key-here
44

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

88
# API Base URL (usually doesn't need to change)
9-
VITE_TAILSCALE_BASE_URL=https://api.tailscale.com/api/v2
9+
PROXY_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.VITE_TAILSCALE_API_KEY;
22-
const tailnet = process.env.VITE_TAILSCALE_TAILNET;
21+
const apiKey = process.env.TAILSCALE_ACCESS_TOKEN;
22+
const tailnet = process.env.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.VITE_TAILSCALE_API_KEY
16-
const envTailnet = import.meta.env.VITE_TAILSCALE_TAILNET
17-
const envBaseUrl = import.meta.env.VITE_TAILSCALE_BASE_URL
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
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.VITE_TAILSCALE_API_KEY
34-
const envTailnet = import.meta.env.VITE_TAILSCALE_TAILNET
33+
const envApiKey = import.meta.env.TAILSCALE_ACCESS_TOKEN
34+
const envTailnet = import.meta.env.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 VITE_TAILSCALE_API_KEY and VITE_TAILSCALE_TAILNET</p>
314+
<p><strong>Environment Variables:</strong> Set TAILSCALE_ACCESS_TOKEN and 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 VITE_TAILSCALE_API_KEY: string
5-
readonly VITE_TAILSCALE_TAILNET: string
6-
readonly VITE_TAILSCALE_BASE_URL: string
4+
readonly TAILSCALE_ACCESS_TOKEN: string
5+
readonly TAILSCALE_TAILNET: string
6+
readonly PROXY_TAILSCALE_BASE_URL: string
77
}
88

99
interface ImportMeta {

0 commit comments

Comments
 (0)