From c67887956138e18bbf0247a44aa811deda0334bf Mon Sep 17 00:00:00 2001 From: Stefan Ecker Date: Wed, 18 Sep 2024 21:31:03 +0200 Subject: [PATCH] Add Docker Compose Action with health checks --- .github/workflows/test-docker.yml | 34 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test-docker.yml b/.github/workflows/test-docker.yml index f97fb03..b56c22b 100644 --- a/.github/workflows/test-docker.yml +++ b/.github/workflows/test-docker.yml @@ -1,6 +1,5 @@ name: Test Docker Compose -# Trigger the workflow on push or pull request to the main branch on: push: branches: @@ -15,36 +14,37 @@ jobs: steps: # Step 1: Checkout the code from the repository - - name: Checkout code - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - # Step 2: Set up Docker - - name: Set up Docker - uses: docker/setup-buildx-action@v1 + # Step 2: Use Docker Compose Action to build and run services + - name: Run docker-compose + uses: hoverkraft-tech/compose-action@v2.0.1 + with: + compose-file: "./docker-compose.yml" + command: "up -d" - # Step 3: Run Docker Compose to start all services - - name: Start Docker Compose - run: docker-compose up -d - - # Step 4: Wait for services to be fully started (optional) + # Step 3: Wait for services to initialize (optional) - name: Wait for services to initialize run: sleep 20 - # Step 5: Health check for VitePress service (port 3001) + # Step 4: Health check for VitePress service (port 3001) - name: Check VitePress health run: | curl -f http://localhost:3001 || exit 1 - # Step 6: Health check for HTTP server (port 4000) + # Step 5: Health check for HTTP server (port 4000) - name: Check HTTP server health run: | curl -f http://localhost:4000 || exit 1 - # Step 7: Health check for Nginx service (port 80) + # Step 6: Health check for Nginx service (port 80) - name: Check Nginx health run: | curl -f http://localhost || exit 1 - # Step 8: Shut down Docker Compose and clean up - - name: Shut down Docker Compose - run: docker-compose down + # Step 7: Shut down Docker Compose and clean up + - name: Stop docker-compose + uses: hoverkraft-tech/compose-action@v2.0.1 + with: + compose-file: "./docker-compose.yml" + command: "down"