Skip to content

Commit 0db143d

Browse files
Add web frontend and Docker deployment
Introduce a new web frontend and containerized deployment setup. Adds a Vite/React+TypeScript web scaffold (package.json, src/, index.html, tailwind/postcss configs, tsconfig, and package-lock) plus an Nginx config for proxying /api to the Go gateway and SPA fallback. Add Dockerfiles for the Go gateway and the web app, and a docker-compose.yml that defines gateway and web services (ports, healthcheck, volume for gateway data, and gateway dependency for web). Update .gitignore to exclude frontend node_modules and build outputs.
1 parent 757cb27 commit 0db143d

25 files changed

Lines changed: 4239 additions & 0 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ go.work.sum
3333

3434
# Local generated synthetic datasets (never commit)
3535
.local/
36+
37+
# Frontend build outputs and dependencies
38+
web/node_modules/
39+
web/dist/

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# ---- build stage -----------------------------------------------------------
2+
FROM golang:1.25-rc-alpine AS builder
3+
WORKDIR /app
4+
5+
COPY go.mod go.sum ./
6+
RUN go mod download
7+
8+
COPY . .
9+
# CGO_ENABLED=1 is required by modernc.org/sqlite (pure-Go, but uses cgo stubs)
10+
RUN CGO_ENABLED=0 GOOS=linux go build -o gateway ./cmd/gateway
11+
12+
# ---- runtime stage ---------------------------------------------------------
13+
FROM alpine:3.20
14+
WORKDIR /app
15+
16+
COPY --from=builder /app/gateway .
17+
COPY configs/ configs/
18+
19+
EXPOSE 8080
20+
CMD ["./gateway"]

docker-compose.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
services:
2+
gateway:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
ports:
7+
- "8080:8080"
8+
environment:
9+
# Leave empty to use SQLite (zero-config default).
10+
# Set to a postgres:// DSN to switch to PostgreSQL.
11+
- DATABASE_URL=
12+
- CONFIG_PATH=configs/config.example.yaml
13+
volumes:
14+
- ./configs:/app/configs:ro
15+
- gateway-data:/app/.local
16+
restart: unless-stopped
17+
healthcheck:
18+
test: ["CMD", "wget", "-qO-", "http://localhost:8080/healthz"]
19+
interval: 15s
20+
timeout: 5s
21+
retries: 3
22+
23+
web:
24+
build:
25+
context: ./web
26+
dockerfile: Dockerfile
27+
ports:
28+
- "3000:80"
29+
depends_on:
30+
gateway:
31+
condition: service_healthy
32+
restart: unless-stopped
33+
34+
volumes:
35+
gateway-data:

web/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# ---- build stage -----------------------------------------------------------
2+
FROM node:22-alpine AS builder
3+
WORKDIR /app
4+
5+
COPY package.json package-lock.json* ./
6+
RUN npm ci
7+
8+
COPY . .
9+
RUN npm run build
10+
11+
# ---- runtime stage ---------------------------------------------------------
12+
FROM nginx:1.27-alpine
13+
COPY --from=builder /app/dist /usr/share/nginx/html
14+
COPY nginx.conf /etc/nginx/conf.d/default.conf
15+
EXPOSE 80

web/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>VeriFHIR Gateway</title>
7+
</head>
8+
<body>
9+
<div id="root"></div>
10+
<script type="module" src="/src/main.tsx"></script>
11+
</body>
12+
</html>

web/nginx.conf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
server {
2+
listen 80;
3+
root /usr/share/nginx/html;
4+
index index.html;
5+
6+
# Proxy API calls to the Go gateway service
7+
location /api/ {
8+
proxy_pass http://gateway:8080;
9+
proxy_http_version 1.1;
10+
proxy_set_header Host $host;
11+
proxy_set_header X-Real-IP $remote_addr;
12+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
13+
proxy_set_header X-Forwarded-Proto $scheme;
14+
}
15+
16+
location /healthz {
17+
proxy_pass http://gateway:8080;
18+
}
19+
20+
location /readyz {
21+
proxy_pass http://gateway:8080;
22+
}
23+
24+
# SPA fallback — return index.html for any non-asset path
25+
location / {
26+
try_files $uri $uri/ /index.html;
27+
}
28+
}

0 commit comments

Comments
 (0)