Skip to content

Commit

Permalink
Add Docker Compose Action with health checks
Browse files Browse the repository at this point in the history
  • Loading branch information
SteEcker committed Sep 18, 2024
1 parent f60e612 commit c678879
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/test-docker.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Test Docker Compose

# Trigger the workflow on push or pull request to the main branch
on:
push:
branches:
Expand All @@ -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/[email protected]
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/[email protected]
with:
compose-file: "./docker-compose.yml"
command: "down"

0 comments on commit c678879

Please sign in to comment.