deployment stuff

This commit is contained in:
Thomas Faour 2025-06-21 23:52:16 -04:00
parent b6aded5281
commit bfb0eae32c
6 changed files with 14 additions and 31 deletions

View File

@ -98,7 +98,7 @@ server {
server_name api.yourdomain.com; server_name api.yourdomain.com;
location / { location / {
proxy_pass http://localhost:3000; proxy_pass http://localhost:4395;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@ -142,7 +142,7 @@ RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/
WORKDIR /app WORKDIR /app
COPY --from=rust-builder /app/target/release/api_server ./ COPY --from=rust-builder /app/target/release/api_server ./
COPY --from=web-builder /app/dist ./static COPY --from=web-builder /app/dist ./static
EXPOSE 3000 EXPOSE 4395
CMD ["./api_server"] CMD ["./api_server"]
``` ```
@ -150,14 +150,14 @@ Build and run:
```bash ```bash
docker build -t orbital-simulator . docker build -t orbital-simulator .
docker run -p 3000:3000 orbital-simulator docker run -p 4395:4395 orbital-simulator
``` ```
## Configuration ## Configuration
### Environment Variables ### Environment Variables
- `PORT`: Server port (default: 3000) - `PORT`: Server port (default: 4395)
- `HOST`: Server host (default: 0.0.0.0) - `HOST`: Server host (default: 0.0.0.0)
- `STATIC_DIR`: Directory for static files (default: web/dist) - `STATIC_DIR`: Directory for static files (default: web/dist)
- `LOG_LEVEL`: Logging level (debug, info, warn, error) - `LOG_LEVEL`: Logging level (debug, info, warn, error)

View File

@ -98,11 +98,11 @@ RUN mkdir -p logs && \
USER appuser USER appuser
# Expose port # Expose port
EXPOSE 3000 EXPOSE 4395
# Health check # Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/api/configs || exit 1 CMD curl -f http://localhost:4395/api/configs || exit 1
# Start the application # Start the application
CMD ["./api_server"] CMD ["./api_server"]

View File

@ -6,37 +6,20 @@ services:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
ports: ports:
- "3000:3000" - "4395:4395"
environment: environment:
- RUST_LOG=info - RUST_LOG=info
- BIND_ADDRESS=0.0.0.0:3000 - BIND_ADDRESS=0.0.0.0:4395
volumes: volumes:
# Optional: Mount config directory for easy config updates # Optional: Mount config directory for easy config updates
- ./config:/app/config:ro - ./config:/app/config:ro
# Optional: Mount logs directory # Optional: Mount logs directory
- orbital_logs:/app/logs - ./orbital_logs:/app/logs
restart: unless-stopped restart: unless-stopped
healthcheck: healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:3000/api/configs || exit 1"] test: ["CMD-SHELL", "curl -f http://localhost:4395/api/configs || exit 1"]
interval: 30s interval: 30s
timeout: 10s timeout: 10s
retries: 3 retries: 3
start_period: 40s start_period: 40s
# Optional: Add a reverse proxy for production
nginx:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./ssl:/etc/nginx/ssl:ro
depends_on:
- orbital-simulator
restart: unless-stopped
profiles:
- production
volumes:
orbital_logs:

View File

@ -43,7 +43,7 @@ async fn start_api_server() -> Result<String, String> {
cmd.args(&["run", "--release", "--bin", "api_server"]); cmd.args(&["run", "--release", "--bin", "api_server"]);
match cmd.spawn() { match cmd.spawn() {
Ok(_) => Ok("API server started on http://localhost:3000".to_string()), Ok(_) => Ok("API server started on http://localhost:4395".to_string()),
Err(e) => Err(format!("Failed to start API server: {}", e)), Err(e) => Err(format!("Failed to start API server: {}", e)),
} }
} }

View File

@ -513,8 +513,8 @@ pub async fn main() {
// Serve static files for the web frontend // Serve static files for the web frontend
let app = app.nest_service("/", ServeDir::new("web/dist")); let app = app.nest_service("/", ServeDir::new("web/dist"));
println!("🚀 Orbital Simulator API Server starting on http://localhost:3000"); println!("🚀 Orbital Simulator API Server starting on http://localhost:4395");
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); let listener = tokio::net::TcpListener::bind("0.0.0.0:4395").await.unwrap();
axum::serve(listener, app).await.unwrap(); axum::serve(listener, app).await.unwrap();
} }

View File

@ -7,7 +7,7 @@ export default defineConfig({
port: 5173, port: 5173,
proxy: { proxy: {
'/api': { '/api': {
target: 'http://localhost:3000', target: 'http://localhost:4395',
changeOrigin: true, changeOrigin: true,
} }
} }