Skip to content

fix stop compose with linux nogpu #14

fix stop compose with linux nogpu

fix stop compose with linux nogpu #14

Workflow file for this run

name: CI/CD with Docker Compose Linux Host
on:
push:
branches:
- main
jobs:
build-and-test:
runs-on: self-hosted
services:
docker:
image: docker:20.10.9
options: --privileged
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build and start Docker Compose services
run: docker compose -f compose_linux_nogpu.yaml up -d --build
- name: Wait for services to be healthy (optional, but recommended)
# You can use a dedicated action or a script to wait for health checks
# Example using a simple sleep (adjust as needed for your application)
run: sleep 30
- name: Test noVNC is up
run: |
SERVICE_URL="http://localhost:3080"
EXPECTED_RESPONSE="200"
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" $SERVICE_URL)
if [ "$RESPONSE" == "$EXPECTED_RESPONSE" ]; then
echo "Test Passed: Service returned expected response."
echo "Expected: $EXPECTED_RESPONSE"
echo "Actual: $RESPONSE"
exit 0
else
echo "Test Failed: Service response did not match expected response."
echo "Expected: $EXPECTED_RESPONSE"
echo "Actual: $RESPONSE"
exit 1
fi
- name: Test code-server is up
run: |
SERVICE_URL="http://localhost:3081"
EXPECTED_RESPONSE="200"
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" $SERVICE_URL)
if [ "$RESPONSE" == "$EXPECTED_RESPONSE" ]; then
echo "Test Passed: Service returned expected response."
echo "Expected: $EXPECTED_RESPONSE"
echo "Actual: $RESPONSE"
exit 0
else
echo "Test Failed: Service response did not match expected response."
echo "Expected: $EXPECTED_RESPONSE"
echo "Actual: $RESPONSE"
exit 1
fi
- name: Test sshd is up
run: |
EXPECTED_RESPONSE="1"
RESPONSE=$(netstat -an | grep 0.0.0.0:3022 | grep tcp | grep LISTEN | wc -l)
if [ "$RESPONSE" == "$EXPECTED_RESPONSE" ]; then
echo "Test Passed: Service returned expected response."
echo "Expected: $EXPECTED_RESPONSE"
echo "Actual: $RESPONSE"
exit 0
else
echo "Test Failed: Service response did not match expected response."
echo "Expected: $EXPECTED_RESPONSE"
echo "Actual: $RESPONSE"
exit 1
fi
- name: Check running containers (optional for debugging)
run: docker ps -a
- name: Stop and remove containers
run: docker compose -f compose_linux_nogpu.yaml down