From 1f98cc04bfdaf05214cf925822167469f9a7703e Mon Sep 17 00:00:00 2001 From: Mangesh Sangapu Date: Thu, 23 Jul 2026 09:31:21 -0500 Subject: [PATCH] Update Docker images and add healthcheck MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary for .devcontainer/docker-compose.yml: Added startup coordination so the app waits for Postgres to become healthy and Redis to start. Added a Postgres healthcheck using pg_isready to improve container readiness detection. Pinned Postgres from latest to postgres:17 for a more stable, reproducible dev environment. Pinned Redis to redis:7-alpine, which is a smaller, versioned image and can improve image pull time. Removed the obsolete top-level Compose version field to align with modern Docker Compose conventions. Kept the original network_mode: service:db behavior, so the app’s networking model is unchanged. --- .devcontainer/docker-compose.yml | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 21855366..b05ce65e 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3" - services: app: build: @@ -9,27 +7,38 @@ services: volumes: - ..:/workspace:cached - # Overrides default command so things don't shut down after the process ends. + # Keep the development container running. command: sleep infinity - # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. + # Start supporting services before the app container. + depends_on: + db: + condition: service_healthy + redis: + condition: service_started + network_mode: service:db db: - image: postgres:latest + image: postgres:17 restart: unless-stopped + volumes: - postgres-data:/var/lib/postgresql/data + environment: POSTGRES_DB: app POSTGRES_USER: app_user POSTGRES_PASSWORD: app_password - # Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally. - # (Adding the "ports" property to this file will not forward from a Codespace.) + healthcheck: + test: ["CMD-SHELL", "pg_isready -U app_user -d app"] + interval: 5s + timeout: 5s + retries: 10 redis: - image: redis + image: redis:7-alpine restart: unless-stopped volumes: