deployment stuff
This commit is contained in:
parent
b6aded5281
commit
bfb0eae32c
@ -98,7 +98,7 @@ server {
|
||||
server_name api.yourdomain.com;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:3000;
|
||||
proxy_pass http://localhost:4395;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
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
|
||||
COPY --from=rust-builder /app/target/release/api_server ./
|
||||
COPY --from=web-builder /app/dist ./static
|
||||
EXPOSE 3000
|
||||
EXPOSE 4395
|
||||
CMD ["./api_server"]
|
||||
```
|
||||
|
||||
@ -150,14 +150,14 @@ Build and run:
|
||||
|
||||
```bash
|
||||
docker build -t orbital-simulator .
|
||||
docker run -p 3000:3000 orbital-simulator
|
||||
docker run -p 4395:4395 orbital-simulator
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### Environment Variables
|
||||
|
||||
- `PORT`: Server port (default: 3000)
|
||||
- `PORT`: Server port (default: 4395)
|
||||
- `HOST`: Server host (default: 0.0.0.0)
|
||||
- `STATIC_DIR`: Directory for static files (default: web/dist)
|
||||
- `LOG_LEVEL`: Logging level (debug, info, warn, error)
|
||||
|
@ -98,11 +98,11 @@ RUN mkdir -p logs && \
|
||||
USER appuser
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
EXPOSE 4395
|
||||
|
||||
# Health check
|
||||
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
|
||||
CMD ["./api_server"]
|
||||
|
@ -6,37 +6,20 @@ services:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "4395:4395"
|
||||
environment:
|
||||
- RUST_LOG=info
|
||||
- BIND_ADDRESS=0.0.0.0:3000
|
||||
- BIND_ADDRESS=0.0.0.0:4395
|
||||
volumes:
|
||||
# Optional: Mount config directory for easy config updates
|
||||
- ./config:/app/config:ro
|
||||
# Optional: Mount logs directory
|
||||
- orbital_logs:/app/logs
|
||||
- ./orbital_logs:/app/logs
|
||||
restart: unless-stopped
|
||||
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
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
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:
|
||||
|
@ -43,7 +43,7 @@ async fn start_api_server() -> Result<String, String> {
|
||||
cmd.args(&["run", "--release", "--bin", "api_server"]);
|
||||
|
||||
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)),
|
||||
}
|
||||
}
|
||||
|
@ -513,8 +513,8 @@ pub async fn main() {
|
||||
// Serve static files for the web frontend
|
||||
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();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ export default defineConfig({
|
||||
port: 5173,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:3000',
|
||||
target: 'http://localhost:4395',
|
||||
changeOrigin: true,
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user