feat: GeoScene frontend POC + Docker deploy for remote host

Migrate maps to @geoscene/core, polish monitoring/alerts UX, fix timeline
basemap flicker and district alert regions, and ship compose/nginx Docker
deploy assets with CBPOA_ROOT data mounts.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-24 03:28:29 +08:00
parent fe8bed58f5
commit e22b004f9e
77 changed files with 3421 additions and 3589 deletions

View File

@@ -1,32 +1,26 @@
FROM python:3.11-slim
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq-dev \
libpq-dev curl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd --gid 1000 appgroup && \
useradd --uid 1000 --gid appgroup --shell /bin/bash --create-home appuser
WORKDIR /home/appuser
WORKDIR /app
# Copy requirements and install dependencies
COPY --chown=appuser:appgroup requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir -r requirements.txt \
-i https://pypi.tuna.tsinghua.edu.cn/simple
# Copy backend code
COPY --chown=appuser:appgroup . .
# Switch to non-root user
USER appuser
# Expose port
ENV CBPOA_ROOT=/data
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
CMD curl -f http://localhost:8000/docs || exit 1
# Run uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

17
deploy/cbpoa-api.service Normal file
View File

@@ -0,0 +1,17 @@
[Unit]
Description=CBPOA FastAPI backend
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/cbpoa/backend
Environment=PATH=/opt/cbpoa/backend/.venv/bin:/usr/bin
EnvironmentFile=-/opt/cbpoa/backend/.env
ExecStart=/opt/cbpoa/backend/.venv/bin/uvicorn main:app --host 127.0.0.1 --port 8000 --workers 1
Restart=on-failure
RestartSec=5
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target

View File

@@ -1,83 +1,47 @@
version: '3.8'
services:
postgres:
image: postgis/postgis:15-3.3
container_name: wuhan_postgres
environment:
POSTGRES_DB: wuhan_disease
POSTGRES_USER: wuhan_user
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-wuhan_password}
volumes:
- postgres_data:/var/lib/postgresql/data
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U wuhan_user -d wuhan_disease"]
interval: 5s
timeout: 5s
retries: 5
networks:
- wuhan_network
backend:
build:
context: ../backend
dockerfile: Dockerfile
container_name: wuhan_backend
dockerfile: ../deploy/backend/Dockerfile
container_name: cbpoa_backend
environment:
DATABASE_URL: postgresql://wuhan_user:password@postgres:5432/wuhan_disease
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
depends_on:
postgres:
condition: service_healthy
CBPOA_ROOT: /data
CORS_ORIGINS: "*"
volumes:
- ../outputs:/data/outputs:ro
- ../processed:/data/processed:ro
- ../Datas:/data/Datas:ro
ports:
- "8000:8000"
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8000/docs || exit 1"]
interval: 10s
interval: 15s
timeout: 5s
retries: 5
start_period: 30s
start_period: 40s
restart: unless-stopped
networks:
- wuhan_network
- cbpoa_net
frontend:
build:
context: ../frontend
dockerfile: Dockerfile
container_name: wuhan_frontend
environment:
VITE_API_URL: http://localhost:8000
dockerfile: ../deploy/frontend/Dockerfile
container_name: cbpoa_frontend
depends_on:
- backend
backend:
condition: service_healthy
ports:
- "3000:80"
- "80:80"
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:80 || exit 1"]
interval: 10s
test: ["CMD-SHELL", "wget -q -O /dev/null http://localhost/ || exit 1"]
interval: 15s
timeout: 5s
retries: 5
restart: unless-stopped
networks:
- wuhan_network
# jupyter:
# image: jupyter/scipy-notebook:latest
# container_name: wuhan_jupyter
# ports:
# - "8888:8888"
# volumes:
# - ../processed:/home/jovyan/processed
# - ../Datas:/home/jovyan/Datas
# networks:
# - wuhan_network
volumes:
postgres_data:
driver: local
- cbpoa_net
networks:
wuhan_network:
driver: bridge
cbpoa_net:
driver: bridge

View File

@@ -3,4 +3,4 @@ node_modules
*.md
tests
.env*
dist
dist

View File

@@ -5,16 +5,11 @@ FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Install dependencies (using pnpm since lock file is pnpm-lock.yaml)
RUN npm install -g pnpm && pnpm install --frozen-lockfile
# Copy source code
COPY . .
# Build the application
ENV VITE_API_URL=/api
RUN pnpm run build
# =============================================================================
@@ -22,15 +17,10 @@ RUN pnpm run build
# =============================================================================
FROM nginx:alpine AS production
# Copy custom nginx config for SPA routing
COPY --from=builder /app/nginx.conf /etc/nginx/conf.d/default.conf
# Copy built assets from builder
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/dist /usr/share/nginx/html
# Expose port 80
EXPOSE 80
# Health check for nginx
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-redirect --quiet --tries=1 --spider http://localhost/ || exit 1
CMD wget --no-redirect --quiet --tries=1 --spider http://localhost/ || exit 1

37
deploy/nginx-cbpoa.conf Normal file
View File

@@ -0,0 +1,37 @@
server {
listen 80;
server_name _;
root /var/www/cbpoa;
index index.html;
client_max_body_size 20m;
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/geo+json;
gzip_min_length 1000;
location /api/ {
proxy_pass http://127.0.0.1:8000/api/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 120s;
}
# Gaode basemap proxy (same as Vite /basemap-gaode)
location ~ ^/basemap-gaode/(\d+)/(\d+)/(\d+) {
proxy_pass https://webrd01.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&z=$1&x=$2&y=$3;
proxy_set_header Host webrd01.is.autonavi.com;
proxy_ssl_server_name on;
proxy_hide_header Set-Cookie;
expires 1d;
add_header Cache-Control "public";
}
location / {
try_files $uri $uri/ /index.html;
}
}