Skip to content

Commit 848dac8

Browse files
committed
feat: Introduce docker support
1 parent c22e130 commit 848dac8

30 files changed

Lines changed: 1105 additions & 214 deletions

.dockerignore

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Dependencies
2+
node_modules/
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
7+
# Build outputs
8+
.svelte-kit/
9+
build/
10+
dist/
11+
.output/
12+
13+
# Environment files
14+
.env
15+
.env.*
16+
!.env.example
17+
18+
# Testing
19+
coverage/
20+
.nyc_output/
21+
22+
# IDE
23+
.vscode/
24+
.idea/
25+
*.swp
26+
*.swo
27+
*~
28+
29+
# OS files
30+
.DS_Store
31+
Thumbs.db
32+
33+
# Git
34+
.git/
35+
.gitignore
36+
37+
# Documentation
38+
docs/
39+
*.md
40+
!README.md
41+
42+
# CI/CD
43+
.github/
44+
.gitlab-ci.yml
45+
46+
# Storybook
47+
storybook-static/
48+
.storybook/
49+
50+
# Playwright
51+
playwright-report/
52+
test-results/
53+
54+
# Misc
55+
.prettierrc
56+
.eslintrc
57+
eslint.config.js
58+
tsconfig.json
59+
tsconfig.node.json
60+
vite.config.*.ts
61+
vitest-setup-client.ts
62+
playwright.config.ts
63+
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Docker Build and Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- 1.x
8+
tags:
9+
- 'v*'
10+
pull_request:
11+
branches:
12+
- main
13+
- 1.x
14+
15+
env:
16+
REGISTRY: ghcr.io
17+
IMAGE_NAME: ${{ github.repository }}
18+
19+
jobs:
20+
build-and-push:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
- name: Log in to Container Registry
34+
if: github.event_name != 'pull_request'
35+
uses: docker/login-action@v3
36+
with:
37+
registry: ${{ env.REGISTRY }}
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Extract metadata
42+
id: meta
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
46+
tags: |
47+
type=ref,event=branch
48+
type=ref,event=pr
49+
type=semver,pattern={{version}}
50+
type=semver,pattern={{major}}.{{minor}}
51+
type=semver,pattern={{major}}
52+
type=sha
53+
54+
- name: Build and push Docker image
55+
uses: docker/build-push-action@v5
56+
with:
57+
context: .
58+
push: ${{ github.event_name != 'pull_request' }}
59+
tags: ${{ steps.meta.outputs.tags }}
60+
labels: ${{ steps.meta.outputs.labels }}
61+
cache-from: type=gha
62+
cache-to: type=gha,mode=max
63+
platforms: linux/amd64,linux/arm64
64+
65+
- name: Image digest
66+
run: echo ${{ steps.meta.outputs.digest }}
67+

CHANGELOG.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,58 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.0.15] - 2025-11-19
9+
10+
### Added
11+
12+
- **Runtime Configuration**: Application now supports runtime environment variables, enabling "build once, deploy anywhere"
13+
- Set `FLOWDROP_API_BASE_URL` (and other `FLOWDROP_*` variables) at runtime instead of build time
14+
- New `/api/config` endpoint serves configuration from server
15+
- New exports: `fetchRuntimeConfig()`, `getRuntimeConfig()`, `initRuntimeConfig()`, `RuntimeConfig` type
16+
- **Docker Support**: Production-ready Dockerfile and docker-compose.yml included
17+
- Multi-stage build with optimized image size
18+
- Health checks and non-root user security
19+
- See `DOCKER.md` for quick start
20+
- **Documentation**: Added deployment guides (`DEPLOYMENT.md`, `DOCKER.md`, `QUICK_START.md`, `MIGRATION_GUIDE.md`)
21+
22+
### Changed
23+
24+
- **Environment Variables**: Production now uses `FLOWDROP_*` prefix instead of `VITE_*`
25+
- `FLOWDROP_API_BASE_URL`: Your backend API URL
26+
- `FLOWDROP_THEME`: UI theme (light/dark/auto)
27+
- `FLOWDROP_TIMEOUT`: Request timeout in milliseconds
28+
- `FLOWDROP_AUTH_TYPE`: Authentication type
29+
- `FLOWDROP_AUTH_TOKEN`: Authentication token
30+
- Development mode still supports `VITE_*` variables for backward compatibility
31+
32+
### Fixed
33+
34+
- **Critical**: Fixed race condition where API requests used wrong URL (localhost instead of configured URL)
35+
- Configuration now loads on server before page render
36+
- All API requests now use correct configured URL from first request
37+
38+
### Breaking Changes
39+
40+
- If using `getDevConfig()` or `getDevApiConfig()` directly, these are now async functions
41+
- Update environment variables from `VITE_*` to `FLOWDROP_*` for production deployments
42+
- See `MIGRATION_GUIDE.md` for detailed migration steps
43+
44+
### Usage
45+
46+
**Docker (Recommended):**
47+
```bash
48+
docker run -p 3000:3000 \
49+
-e FLOWDROP_API_BASE_URL=https://your-api.com/api/flowdrop \
50+
flowdrop-ui:latest
51+
```
52+
53+
**Environment Variables:**
54+
```bash
55+
export FLOWDROP_API_BASE_URL=https://your-api.com/api/flowdrop
56+
npm run build
57+
node build
58+
```
59+
860
## [0.0.14] - 2025-11-12
961

1062
### Fixed
@@ -275,7 +327,15 @@ import '@d34dman/flowdrop/styles/base.css';
275327

276328
---
277329

278-
[Unreleased]: https://github.com/d34dman/flowdrop/compare/v0.0.7...HEAD
330+
[Unreleased]: https://github.com/d34dman/flowdrop/compare/v0.0.15...HEAD
331+
[0.0.15]: https://github.com/d34dman/flowdrop/compare/v0.0.14...v0.0.15
332+
[0.0.14]: https://github.com/d34dman/flowdrop/compare/v0.0.13...v0.0.14
333+
[0.0.13]: https://github.com/d34dman/flowdrop/compare/v0.0.12...v0.0.13
334+
[0.0.12]: https://github.com/d34dman/flowdrop/compare/v0.0.11...v0.0.12
335+
[0.0.11]: https://github.com/d34dman/flowdrop/compare/v0.0.10...v0.0.11
336+
[0.0.10]: https://github.com/d34dman/flowdrop/compare/v0.0.9...v0.0.10
337+
[0.0.9]: https://github.com/d34dman/flowdrop/compare/v0.0.8...v0.0.9
338+
[0.0.8]: https://github.com/d34dman/flowdrop/compare/v0.0.7...v0.0.8
279339
[0.0.7]: https://github.com/d34dman/flowdrop/compare/v0.0.6...v0.0.7
280340
[0.0.6]: https://github.com/d34dman/flowdrop/compare/v0.0.5...v0.0.6
281341
[0.0.5]: https://github.com/d34dman/flowdrop/compare/v0.0.4...v0.0.5

DOCKER.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Docker Quick Start Guide
2+
3+
This guide provides quick instructions for running FlowDrop UI with Docker.
4+
5+
## Prerequisites
6+
7+
- Docker installed (version 20.10 or higher)
8+
- Docker Compose installed (version 2.0 or higher)
9+
10+
## Quick Start
11+
12+
### 1. Setup Environment Variables
13+
14+
Copy the example environment file:
15+
16+
```bash
17+
cp env.example .env
18+
```
19+
20+
Edit `.env` and update the FlowDrop backend API URL:
21+
22+
```bash
23+
FLOWDROP_API_BASE_URL=http://your-backend-server:8080/api/flowdrop
24+
```
25+
26+
### 2. Start with Docker Compose
27+
28+
```bash
29+
docker-compose up -d
30+
```
31+
32+
### 3. Access the Application
33+
34+
Open your browser and navigate to:
35+
36+
```
37+
http://localhost:3000
38+
```
39+
40+
## Docker Commands
41+
42+
### Build the image
43+
44+
```bash
45+
docker build -t flowdrop-ui:latest .
46+
```
47+
48+
### Run the container
49+
50+
```bash
51+
docker run -d \
52+
--name flowdrop-ui \
53+
-p 3000:3000 \
54+
-e FLOWDROP_API_BASE_URL=http://your-backend:8080/api/flowdrop \
55+
flowdrop-ui:latest
56+
```
57+
58+
### View logs
59+
60+
```bash
61+
docker logs -f flowdrop-ui
62+
```
63+
64+
### Stop the container
65+
66+
```bash
67+
docker-compose down
68+
```
69+
70+
### Restart the container
71+
72+
```bash
73+
docker-compose restart
74+
```
75+
76+
## Environment Variables
77+
78+
Key environment variables you can configure:
79+
80+
| Variable | Description | Default |
81+
|----------|-------------|---------|
82+
| `FLOWDROP_API_BASE_URL` | Backend API URL | `/api/flowdrop` |
83+
| `FLOWDROP_THEME` | UI theme (light/dark/auto) | `auto` |
84+
| `PORT` | Server port | `3000` |
85+
86+
See `env.example` for all available options.
87+
88+
## Troubleshooting
89+
90+
### Container won't start
91+
92+
Check logs:
93+
```bash
94+
docker logs flowdrop-ui
95+
```
96+
97+
### Can't connect to backend
98+
99+
Verify the API URL is accessible from within the container:
100+
```bash
101+
docker exec flowdrop-ui wget -qO- http://your-backend:8080/api/flowdrop/nodes
102+
```
103+
104+
### Port already in use
105+
106+
Change the external port in docker-compose.yml:
107+
```yaml
108+
ports:
109+
- "3001:3000" # Change 3001 to any available port
110+
```
111+
112+
## Health Check
113+
114+
Verify the application is running:
115+
116+
```bash
117+
curl http://localhost:3000/api/config
118+
```
119+
120+
Expected response:
121+
```json
122+
{
123+
"apiBaseUrl": "http://your-backend:8080/api/flowdrop",
124+
"theme": "auto",
125+
"timeout": 30000,
126+
"authType": "none",
127+
"version": "1.0.0",
128+
"environment": "production"
129+
}
130+
```
131+
132+
## Production Deployment
133+
134+
For production deployment instructions, see [DEPLOYMENT.md](./DEPLOYMENT.md).
135+

0 commit comments

Comments
 (0)