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
7feaa231
Commit
7feaa231
authored
Sep 07, 2025
by
Abhishek
Browse files
Update .gitlab-ci.yml file
parent
ac4da2e6
Pipeline
#11822
failed with stages
in 5 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
7feaa231
image
:
docker:20.10.16
# Docker image to run your jobs
stages
:
stages
:
-
full_test
-
deploy
-
test
-
cleanup
variables
:
variables
:
DOCKER_TLS_CERTDIR
:
"
"
# Disable TLS for Docker
MOODLE_URL
:
"
http://web:80"
EUSER
:
"
appuser"
DOCKER_REGISTRY_IMAGE
:
"
registry.example.com/yourproject/moodle-web:latest"
EGID
:
"
999"
MOODLE_WWWROOT
:
"
http://host.docker.internal:8080"
# Use host.docker.internal for WSL
deploy_moodle
:
MOODLE_URL
:
"
http://host.docker.internal:8080"
stage
:
deploy
MOODLE_ADMIN_USER
:
"
user"
image
:
docker:20.10.24
# Only the CLI
MOODLE_ADMIN_PASS
:
"
QAYwsx@12345"
services
:
[]
script
:
# Pull your prebuilt image
-
docker pull $DOCKER_REGISTRY_IMAGE
# Start DB container
-
docker run -d --name moodle-db \
-e MARIADB_ROOT_PASSWORD=verysecretpassword \
-e MARIADB_DATABASE=moodle \
-e MARIADB_USER=moodleuser \
-e MARIADB_PASSWORD=moodlepassword \
mariadb:10.6 \
--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
# Start Moodle container using the pulled image
-
docker run -d --name moodle-web --link moodle-db:db \
-p 8080:80 \
-v moodledata:/var/www/moodledata \
$DOCKER_REGISTRY_IMAGE
# Wait for Moodle to be ready
-
sleep
60
artifacts
:
expire_in
:
1h
paths
:
-
docker-compose.yml
run_tests
:
stage
:
test
image
:
docker:20.10.24
script
:
# Execute your automation script inside the running container
-
docker exec moodle-web bash -c "/usr/local/bin/setup-and-test.sh"
run_full_automation
:
cleanup
:
stage
:
full_test
stage
:
cleanup
when
:
manual
image
:
docker:20.10.24
before_script
:
-
apk add --no-cache curl docker-compose bash jq
-
echo "Docker version:"
-
docker --version
-
echo "Docker Compose version:"
-
docker-compose --version
-
echo "Checking Docker socket..."
-
ls -l /var/run/docker.sock || echo "Docker socket not found!"
-
echo "Verifying Docker daemon..."
-
docker info || { echo "Failed to connect to Docker daemon!"; exit 1; }
-
echo "Setting up named volume..."
-
docker volume create cota-infra_dta_tests_data
-
echo "Setting permissions on dta_tests_data volume..."
-
docker run --rm -v cota-infra_dta_tests_data:/data alpine chown 137:137 /data
script
:
script
:
-
echo "Creating .env file for Docker Compose..."
-
docker stop moodle-web moodle-db
-
echo "MOODLE_WWWROOT=${MOODLE_WWWROOT}" > .env
-
docker rm moodle-web moodle-db
-
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 "Starting Docker environment..."
-
docker-compose up -d
-
echo "Docker Compose services:"
-
docker-compose ps
-
echo "Waiting for Moodle first-time installation to complete..."
-
|
timeout=300
while ! docker exec moodle-web-official [ -f /var/www/html/config.php ]; do
timeout=$((timeout - 5))
if [ $timeout -le 0 ]; then
echo "❌ ERROR: Moodle installation timed out after 5 minutes."
docker logs moodle-web-official
exit 1
fi
echo " -> Installation not yet complete, waiting 5 more seconds..."
sleep 5
done
-
echo "✅ Moodle installation complete (config.php found)."
-
chmod +x test-moodle.sh
-
echo "Executing the main automation script..."
-
./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