services: postgres: image: postgres:16-alpine restart: unless-stopped environment: POSTGRES_USER: ${POSTGRES_USER:-simplecrm} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-simplecrm_dev} POSTGRES_DB: ${POSTGRES_DB:-simplecrm_development} TZ: Europe/Rome PGTZ: Europe/Rome volumes: - postgres_data:/var/lib/postgresql/data # Non esporre 5432 sull'host per evitare conflitti; web raggiunge postgres via rete Docker. # Per accesso esterno: ports: ["5433:5432"] healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-simplecrm} -d ${POSTGRES_DB:-simplecrm_development}"] interval: 5s timeout: 5s retries: 10 web: build: context: . dockerfile: Dockerfile target: development restart: unless-stopped command: bash -c "bundle check || bundle install && bin/rails tailwindcss:build && rm -f tmp/pids/server.pid && bin/rails db:prepare && bin/rails db:seed && bin/rails server -b 0.0.0.0 -p 3000" environment: RAILS_ENV: ${RAILS_ENV:-development} DATABASE_HOST: postgres DATABASE_PORT: 5432 POSTGRES_USER: ${POSTGRES_USER:-simplecrm} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-simplecrm_dev} POSTGRES_DB: ${POSTGRES_DB:-simplecrm_development} SECRET_KEY_BASE: ${SECRET_KEY_BASE} MAILER_FROM: ${MAILER_FROM:-noreply@simplecrm.local} APP_HOST: ${APP_HOST:-localhost} APP_PORT: ${APP_PORT:-3000} TZ: Europe/Rome MAILING_POLLER: "true" volumes: - .:/rails - bundle_cache:/usr/local/bundle ports: - "${APP_PORT:-3001}:3000" depends_on: postgres: condition: service_healthy stdin_open: true tty: true volumes: postgres_data: bundle_cache: