-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Docker Compose Action with health checks
- Loading branch information
Showing
1 changed file
with
17 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|
@@ -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" |