services: app: build: context: . dockerfile: resources/docker/Dockerfile args: PHP_VERSION: ${PHP_VERSION:-8.4} PHALCON_VARIANT: ${PHALCON_VARIANT:-v5} UID: ${UID:-1000} GID: ${GID:-1000} container_name: ${PROJECT_PREFIX:-rest-api}-app hostname: ${PROJECT_PREFIX:-rest-api}-app volumes: - .:/srv env_file: .env depends_on: mysql: condition: service_healthy redis: condition: service_healthy nginx: image: nginx:alpine container_name: ${PROJECT_PREFIX:-rest-api}-nginx hostname: ${PROJECT_PREFIX:-rest-api}-nginx ports: # Host port is configurable (APP_PORT) so multiple apps can coexist; # the container always listens on 80. - "${APP_PORT:-8080}:80" volumes: - .:/srv - ./resources/docker/nginx/default.conf:/etc/nginx/conf.d/default.conf depends_on: - app mysql: image: mysql:8.0 container_name: ${PROJECT_PREFIX:-rest-api}-mysql environment: MYSQL_ROOT_PASSWORD: ${DATA_API_MYSQL_PASS:-secret} MYSQL_DATABASE: ${DATA_API_MYSQL_NAME:-phalcon_api} # No host port published: the app reaches the DB over the internal compose # network as mysql:3306. Not exposed to the host by design. healthcheck: test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-p${DATA_API_MYSQL_PASS:-secret}"] interval: 5s timeout: 5s retries: 12 redis: image: redis:alpine container_name: ${PROJECT_PREFIX:-rest-api}-redis # No host port published: the app reaches the cache over the internal # compose network as redis:6379. Not exposed to the host by design. healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 5s retries: 12