Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CoTA
cota-infra
Commits
2b46065e
Commit
2b46065e
authored
Sep 23, 2025
by
Abhishek
Browse files
Update .gitlab-ci.yml file with dind
parent
e0e9b8cb
Pipeline
#11948
failed
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
2b46065e
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
echo " -> Backend not ready, retrying in 5s"
sleep 5
done
-
echo "✅ Backend port is open."
-
echo "⏳ Checking backend health endpoint..."
script
:
-
|
# --- THIS IS THE FIX ---
if curl -s -f $BACKEND_URL/actuator/health >/dev/null; then
# Create a .env file on the fly. Docker Compose will automatically read this
echo "✅ Backend health endpoint OK"
# file and pass the variables to the containers.
else
-
echo "Creating .env file for Docker Compose..."
echo "⚠️ Backend health endpoint not available, continuing anyway"
-
echo "MOODLE_WWWROOT=${MOODLE_WWWROOT}" > .env
fi
-
echo "MOODLE_ADMIN_USER=${MOODLE_ADMIN_USER}" >> .env
-
echo "MOODLE_ADMIN_PASS=${MOODLE_ADMIN_PASS}" >> .env
-
echo "EUSER=${EUSER}" >> .env
-
echo "EGID=${EGID}" >> .env
-
timeout=300
-
echo "Starting Docker environment..."
-
echo "⏳ Waiting for Moodle web server to be ready..."
-
docker-compose up -d
# Loop until the Moodle installation is complete.
-
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 y
et,
retrying in 5
s..."
echo " ->
Installation not yet compl
et
e
,
waiting 5 more second
s..."
sleep 5
sleep 5
done
done
-
echo "✅ Moodle i
s live
"
-
echo "✅ Moodle i
nstallation 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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment