Commit 0525b251 authored by Abhishek's avatar Abhishek
Browse files

Update .gitlab-ci.yml file

parent 4521e2e1
Pipeline #11824 failed with stage
in 53 seconds
image: registry.example.com/yourproject/moodle-web:latest # your Moodle image in registry
stages:
- deploy
- test
- cleanup
- full_test
# GitLab services: MariaDB + Backend
services:
- name: mariadb:10.6
alias: db
- name: hftstuttgart/cota-backend:latest
alias: backend
variables:
MOODLE_URL: "http://web:80"
DOCKER_REGISTRY_IMAGE: "41abku1mst/moodle-web:latest"
# Moodle settings
MOODLE_URL: "http://localhost"
MOODLE_WWWROOT: "http://localhost"
MOODLE_ADMIN_USER: "user"
MOODLE_ADMIN_PASS: "QAYwsx@12345"
deploy_moodle:
stage: deploy
image: docker:20.10.24 # Only the CLI
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"
# MariaDB settings
MARIADB_ROOT_PASSWORD: verysecretpassword
MARIADB_DATABASE: moodle
MARIADB_USER: moodleuser
MARIADB_PASSWORD: moodlepassword
cleanup:
stage: cleanup
image: docker:20.10.24
# Backend port (internal GitLab service network)
BACKEND_URL: "http://backend:8080"
run_full_automation:
stage: full_test
script:
- docker stop moodle-web moodle-db
- docker rm moodle-web moodle-db
# 1. Start Apache in background
- echo "🚀 Starting Apache..."
- apache2ctl -D FOREGROUND &
- sleep 10
# 2. Wait for MariaDB service
- echo "⏳ Waiting for MariaDB..."
- until mysqladmin ping -h"db" --silent; do
echo " -> DB not ready, retrying in 5s";
sleep 5;
done
- echo "✅ MariaDB is ready."
# 3. Wait for backend
- echo "⏳ Waiting for backend..."
- until curl -s -f -o /dev/null http://backend:8080/actuator/health; do
echo " -> Backend not ready, retrying in 5s";
sleep 5;
done
- echo "✅ Backend is ready."
# 4. Run Moodle + Backend orchestration
- echo "▶️ Running full Moodle automation..."
- chmod +x test-moodle.sh
- ./test-moodle.sh
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