Commit 2b46065e authored by Abhishek's avatar Abhishek
Browse files

Update .gitlab-ci.yml file with dind

parent e0e9b8cb
Pipeline #11948 failed
image: 41abku1mst/moodle-web:latest # your Moodle image in registry # This GitLab CI/CD pipeline is designed to run the complete Moodle
# automation script in a single, manually triggered job.
stages: image: docker:20.10.16
- full_test
services: services:
- name: mariadb:10.6 - name: docker:20.10.16-dind
alias: db alias: docker
- name: hftstuttgart/cota-backend:latest
alias: backend stages:
- full_test
variables: variables:
# Moodle settings DOCKER_HOST: tcp://docker:2375
MOODLE_URL: "http://localhost" DOCKER_TLS_CERTDIR: ""
MOODLE_WWWROOT: "http://localhost" EUSER: "appuser"
EGID: "137"
MOODLE_WWWROOT: "http://docker:8080" # For the entrypoint installation
MOODLE_URL: "http://docker:8080" # For the test script's curl commands
# Add the admin credentials here so they are also written to the .env file
MOODLE_ADMIN_USER: "user" MOODLE_ADMIN_USER: "user"
MOODLE_ADMIN_PASS: "QAYwsx@12345" MOODLE_ADMIN_PASS: "QAYwsx@12345"
# MariaDB settings
MARIADB_ROOT_PASSWORD: verysecretpassword
MARIADB_DATABASE: moodle
MARIADB_USER: moodleuser
MARIADB_PASSWORD: moodlepassword
# Backend URL
BACKEND_URL: "http://backend:8080"
run_full_automation: run_full_automation:
stage: full_test stage: full_test
script: when: manual
- apt-get update && apt-get install -y curl netcat-openbsd
- echo "🚀 Starting Apache..."
- apache2ctl -D FOREGROUND &
- sleep 10
- echo "⏳ Waiting for MariaDB..." before_script:
- timeout=180 - apk add --no-cache curl docker-compose bash jq
- | - until docker info > /dev/null 2>&1; do echo "Waiting for Docker daemon..."; sleep 3; done
until mysqladmin ping -h"db" --silent; do
timeout=$((timeout - 5))
if [ $timeout -le 0 ]; then
echo "❌ MariaDB did not start after 3 minutes."
exit 1
fi
echo " -> DB not ready, retrying in 5s"
sleep 5
done
- echo "✅ MariaDB is ready."
- echo "⏳ Waiting for backend:8080..." # --- THIS IS THE FIX ---
- timeout=180 # 1. Explicitly create the named volume so we know it exists.
- | - docker volume create cota-infra_dta_tests_data
until nc -z backend 8080; do # 2. Run a temporary container that mounts this volume and changes the ownership
timeout=$((timeout - 5)) # of the directory to user 137, which is the 'appuser' inside the backend container.
if [ $timeout -le 0 ]; then - echo "Setting permissions on dta_tests_data volume..."
echo "❌ Backend port 8080 not reachable after 3 minutes." - docker run --rm -v cota-infra_dta_tests_data:/data alpine chown 137:137 /data
exit 1
fi script:
echo " -> Backend not ready, retrying in 5s" # --- THIS IS THE FIX ---
sleep 5 # Create a .env file on the fly. Docker Compose will automatically read this
done # file and pass the variables to the containers.
- echo "✅ Backend port is open." - echo "Creating .env file for Docker Compose..."
- echo "MOODLE_WWWROOT=${MOODLE_WWWROOT}" > .env
- echo "MOODLE_ADMIN_USER=${MOODLE_ADMIN_USER}" >> .env
- echo "MOODLE_ADMIN_PASS=${MOODLE_ADMIN_PASS}" >> .env
- echo "EUSER=${EUSER}" >> .env
- echo "EGID=${EGID}" >> .env
- echo "⏳ Checking backend health endpoint..." - echo "Starting Docker environment..."
- | - docker-compose up -d
if curl -s -f $BACKEND_URL/actuator/health >/dev/null; then
echo "✅ Backend health endpoint OK"
else
echo "⚠️ Backend health endpoint not available, continuing anyway"
fi
- timeout=300 # Loop until the Moodle installation is complete.
- echo "Waiting for Moodle web server to be ready..." - echo "Waiting for Moodle first-time installation to complete..."
- | - |
until curl -s -f http://localhost >/dev/null; do timeout=300
while ! docker exec moodle-web-official [ -f /var/www/html/config.php ]; do
timeout=$((timeout - 5)) timeout=$((timeout - 5))
if [ $timeout -le 0 ]; then if [ $timeout -le 0 ]; then
echo "❌ Moodle did not become ready in 5 minutes" echo "❌ ERROR: Moodle installation timed out after 5 minutes."
docker logs moodle-web-official
exit 1 exit 1
fi fi
echo " -> Moodle not ready yet, retrying in 5s..." echo " -> Installation not yet complete, waiting 5 more seconds..."
sleep 5 sleep 5
done done
- echo "✅ Moodle is live" - echo "✅ Moodle installation complete (config.php found)."
- echo "▶️ Running Moodle automation..." # Now that Moodle is stable, we can proceed with the rest of the script.
- chmod +x test-moodle.sh - chmod +x test-moodle.sh
- echo "Executing the main automation script..."
- ./test-moodle.sh - ./test-moodle.sh
after_script:
- echo "Tearing down Docker environment..."
- docker-compose down -v
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment