Fix Docker networking and add graceful MongoDB error handling
- Fix DNS resolution: Removed invalid dns_search configuration - Add graceful MongoDB connection error handling - Set restart policy to 'unless-stopped' for both services - Add development helper scripts (start-dev.sh, stop-dev.sh) - Update Docker Compose configurations for development - Restore main.rs from git history - Backend now logs MongoDB errors without crashing All containers now start successfully with proper DNS resolution on the dedicated normogen-network.
This commit is contained in:
parent
177f2ad8e7
commit
cd5c1709c6
7 changed files with 277 additions and 64 deletions
|
|
@ -3,51 +3,46 @@ services:
|
|||
build:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile
|
||||
args:
|
||||
BUILDKIT_INLINE_CACHE: 0
|
||||
pull_policy: build
|
||||
container_name: normogen-backend
|
||||
ports:
|
||||
- '6800:8000'
|
||||
- '8000:8000'
|
||||
environment:
|
||||
- RUST_LOG=info
|
||||
- SERVER_PORT=8000
|
||||
- SERVER_HOST=0.0.0.0
|
||||
- MONGODB_URI=mongodb://mongodb:27017
|
||||
- DATABASE_NAME=normogen
|
||||
env_file:
|
||||
- .env
|
||||
- MONGODB_DATABASE=normogen
|
||||
- JWT_SECRET=${JWT_SECRET:-please-change-this-in-production}
|
||||
depends_on:
|
||||
mongodb:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- normogen-network
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '1.0'
|
||||
memory: 1000M
|
||||
healthcheck:
|
||||
test: ['CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:8000/health']
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
# Disable DNS search domain to fix hostname resolution
|
||||
dns_search: []
|
||||
mongodb:
|
||||
image: mongo:6.0
|
||||
container_name: normogen-mongodb
|
||||
ports:
|
||||
- '27017:27017'
|
||||
environment:
|
||||
- MONGO_INITDB_DATABASE=normogen
|
||||
volumes:
|
||||
- mongodb_data:/data/db
|
||||
networks:
|
||||
- normogen-network
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ['CMD', 'mongosh', '--eval', 'db.adminCommand.ping()']
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
test: |
|
||||
echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
start_period: 10s
|
||||
start_period: 40s
|
||||
restart: unless-stopped
|
||||
# Disable DNS search domain to fix hostname resolution
|
||||
dns_search: []
|
||||
volumes:
|
||||
mongodb_data:
|
||||
driver: local
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue