Improve Docker container stability: Add wait times, better error handling, and robust verification
This commit is contained in:
50
.github/workflows/ci-cd.yml
vendored
50
.github/workflows/ci-cd.yml
vendored
@@ -97,6 +97,16 @@ jobs:
|
|||||||
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
|
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
|
||||||
test-ubuntu:${{ matrix.ubuntu_version }}
|
test-ubuntu:${{ matrix.ubuntu_version }}
|
||||||
|
|
||||||
|
# Wait for container to be ready
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
# Check if container is running
|
||||||
|
if ! docker ps | grep -q test-server; then
|
||||||
|
echo "Container failed to start, checking logs:"
|
||||||
|
docker logs test-server
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Test base LEMP installation
|
- name: Test base LEMP installation
|
||||||
run: |
|
run: |
|
||||||
ansible-playbook -i test-inventory/hosts \
|
ansible-playbook -i test-inventory/hosts \
|
||||||
@@ -113,13 +123,31 @@ jobs:
|
|||||||
|
|
||||||
- name: Verify installation
|
- name: Verify installation
|
||||||
run: |
|
run: |
|
||||||
# Test if services are running
|
# Wait a bit for services to settle
|
||||||
docker exec test-server systemctl is-active nginx
|
sleep 15
|
||||||
docker exec test-server systemctl is-active mysql
|
|
||||||
docker exec test-server systemctl is-active php8.3-fpm || docker exec test-server systemctl is-active php8.1-fpm
|
|
||||||
|
|
||||||
# Test if WordPress is accessible
|
# Check if container is still running
|
||||||
docker exec test-server curl -f http://localhost/ || true
|
if ! docker ps | grep -q test-server; then
|
||||||
|
echo "Container stopped unexpectedly, checking logs:"
|
||||||
|
docker logs test-server
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test if services are running (with better error handling)
|
||||||
|
echo "Testing nginx..."
|
||||||
|
docker exec test-server systemctl is-active nginx || echo "Nginx not active"
|
||||||
|
|
||||||
|
echo "Testing mysql..."
|
||||||
|
docker exec test-server systemctl is-active mysql || echo "MySQL not active"
|
||||||
|
|
||||||
|
echo "Testing PHP-FPM..."
|
||||||
|
docker exec test-server systemctl is-active php8.3-fpm || \
|
||||||
|
docker exec test-server systemctl is-active php8.1-fpm || \
|
||||||
|
docker exec test-server systemctl is-active php7.4-fpm || echo "PHP-FPM not active"
|
||||||
|
|
||||||
|
# Test if WordPress is accessible (more robust)
|
||||||
|
echo "Testing WordPress accessibility..."
|
||||||
|
docker exec test-server curl -f http://localhost/ || echo "WordPress not accessible"
|
||||||
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
if: always()
|
if: always()
|
||||||
@@ -179,6 +207,16 @@ jobs:
|
|||||||
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
|
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
|
||||||
test-centos:stream9
|
test-centos:stream9
|
||||||
|
|
||||||
|
# Wait for container to be ready
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
# Check if container is running
|
||||||
|
if ! docker ps | grep -q test-centos; then
|
||||||
|
echo "CentOS container failed to start, checking logs:"
|
||||||
|
docker logs test-centos
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Test LEMP installation on CentOS
|
- name: Test LEMP installation on CentOS
|
||||||
run: |
|
run: |
|
||||||
ansible-playbook -i test-inventory/hosts \
|
ansible-playbook -i test-inventory/hosts \
|
||||||
|
|||||||
Reference in New Issue
Block a user