Initial commit: FunConnect project with server, relay, client and admin panel

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-24 20:56:36 +08:00
parent eb6e901440
commit b6891483ae
167 changed files with 16147 additions and 106 deletions

34
docker/Dockerfile.relay Normal file
View File

@@ -0,0 +1,34 @@
# FunMC 中继服务端 Docker 镜像
FROM rust:1.75-slim-bookworm AS builder
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
COPY shared/ ./shared/
COPY relay-server/ ./relay-server/
RUN cargo build --release -p funmc-relay-server
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /app/target/release/relay-server /app/relay-server
ENV RUST_LOG=funmc_relay_server=info
ENV RELAY_LISTEN_ADDR=0.0.0.0:7900
ENV JWT_SECRET=your-jwt-secret-change-in-production
EXPOSE 7900/udp 17900/udp
CMD ["./relay-server"]

35
docker/Dockerfile.server Normal file
View File

@@ -0,0 +1,35 @@
# FunMC 主服务端 Docker 镜像
FROM rust:1.75-slim-bookworm AS builder
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
COPY shared/ ./shared/
COPY server/ ./server/
RUN cargo build --release -p funmc-server
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /app/target/release/server /app/server
COPY server/migrations /app/migrations
ENV RUST_LOG=funmc_server=info
ENV LISTEN_ADDR=0.0.0.0:3000
ENV DATABASE_URL=postgres://postgres:password@db/funmc
EXPOSE 3000 3001
CMD ["./server"]

94
docker/docker-compose.yml Normal file
View File

@@ -0,0 +1,94 @@
version: '3.8'
services:
db:
image: postgres:14-alpine
container_name: funmc-db
restart: unless-stopped
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${DB_PASSWORD:-funmc_password}
POSTGRES_DB: funmc
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
networks:
- funmc-network
server:
build:
context: ..
dockerfile: docker/Dockerfile.server
container_name: funmc-server
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
DATABASE_URL: postgres://postgres:${DB_PASSWORD:-funmc_password}@db/funmc
JWT_SECRET: ${JWT_SECRET:-your-secret-key-change-in-production}
LISTEN_ADDR: 0.0.0.0:3000
RUST_LOG: funmc_server=info,tower_http=info
ports:
- "3000:3000"
- "3001:3001/udp"
networks:
- funmc-network
relay:
build:
context: ..
dockerfile: docker/Dockerfile.relay
container_name: funmc-relay
restart: unless-stopped
environment:
RELAY_LISTEN_ADDR: 0.0.0.0:7900
JWT_SECRET: ${JWT_SECRET:-your-secret-key-change-in-production}
RUST_LOG: funmc_relay_server=info
ports:
- "7900:7900/udp"
- "17900:17900/udp"
networks:
- funmc-network
relay-backup:
build:
context: ..
dockerfile: docker/Dockerfile.relay
container_name: funmc-relay-backup
restart: unless-stopped
environment:
RELAY_LISTEN_ADDR: 0.0.0.0:7901
JWT_SECRET: ${JWT_SECRET:-your-secret-key-change-in-production}
RUST_LOG: funmc_relay_server=info
ports:
- "7901:7901/udp"
- "17901:17901/udp"
networks:
- funmc-network
nginx:
image: nginx:alpine
container_name: funmc-nginx
restart: unless-stopped
depends_on:
- server
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./ssl:/etc/nginx/ssl:ro
networks:
- funmc-network
volumes:
postgres_data:
networks:
funmc-network:
driver: bridge

53
docker/nginx.conf Normal file
View File

@@ -0,0 +1,53 @@
events {
worker_connections 1024;
}
http {
upstream api_server {
server server:3000;
}
server {
listen 80;
server_name funmc.com www.funmc.com;
location / {
return 301 https://$server_name$request_uri;
}
}
server {
listen 443 ssl http2;
server_name funmc.com www.funmc.com;
ssl_certificate /etc/nginx/ssl/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
location /api/ {
proxy_pass http://api_server;
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_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
location /download/ {
alias /var/www/downloads/;
autoindex on;
}
}
}