|
| 1 | +name: Docker Compose Stack Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + test-stack: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + timeout-minutes: 15 |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Add hosts entries |
| 20 | + run: | |
| 21 | + echo -e "127.0.0.1 platform.opentdf.local\n127.0.0.1 keycloak.opentdf.local" | sudo tee -a /etc/hosts |
| 22 | + |
| 23 | + - name: Set up Docker Buildx |
| 24 | + uses: docker/setup-buildx-action@v3 |
| 25 | + |
| 26 | + - name: Setup package registry |
| 27 | + run: | |
| 28 | + # Add Docker's official GPG key: |
| 29 | + sudo apt update |
| 30 | + sudo apt install ca-certificates curl |
| 31 | + sudo install -m 0755 -d /etc/apt/keyrings |
| 32 | + sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc |
| 33 | + sudo chmod a+r /etc/apt/keyrings/docker.asc |
| 34 | +
|
| 35 | + # Add the repository to Apt sources: |
| 36 | + sudo tee /etc/apt/sources.list.d/docker.sources <<EOF |
| 37 | + Types: deb |
| 38 | + URIs: https://download.docker.com/linux/ubuntu |
| 39 | + Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") |
| 40 | + Components: stable |
| 41 | + Signed-By: /etc/apt/keyrings/docker.asc |
| 42 | + EOF |
| 43 | +
|
| 44 | + sudo apt update |
| 45 | +
|
| 46 | + - name: Install Docker Compose |
| 47 | + run: | |
| 48 | + sudo apt-get update |
| 49 | + sudo apt-get install -y docker-compose-plugin |
| 50 | + docker compose version |
| 51 | + |
| 52 | + - name: Start Docker Compose stack |
| 53 | + working-directory: docs/getting-started |
| 54 | + run: | |
| 55 | + docker compose up -d |
| 56 | + |
| 57 | + - name: Wait for platform health check |
| 58 | + run: | |
| 59 | + echo "Waiting for platform to be ready..." |
| 60 | + timeout=900 # 15 minutes in seconds |
| 61 | + elapsed=0 |
| 62 | + interval=5 |
| 63 | + |
| 64 | + while [ $elapsed -lt $timeout ]; do |
| 65 | + echo "Checking health endpoint (${elapsed}s elapsed)..." |
| 66 | + |
| 67 | + # Use -k to allow insecure connections (self-signed cert) |
| 68 | + # Use -s for silent mode, -w for response code |
| 69 | + response=$(curl -k -s -w "\n%{http_code}" https://platform.opentdf.local:8443/healthz 2>/dev/null || echo "") |
| 70 | + |
| 71 | + if [ -n "$response" ]; then |
| 72 | + http_code=$(echo "$response" | tail -n1) |
| 73 | + body=$(echo "$response" | head -n1) |
| 74 | + |
| 75 | + echo "HTTP Code: $http_code" |
| 76 | + echo "Response Body: $body" |
| 77 | + |
| 78 | + if [ "$http_code" = "200" ] && echo "$body" | grep -q '"status":"SERVING"'; then |
| 79 | + echo "✓ Platform is ready!" |
| 80 | + exit 0 |
| 81 | + fi |
| 82 | + fi |
| 83 | + |
| 84 | + sleep $interval |
| 85 | + elapsed=$((elapsed + interval)) |
| 86 | + done |
| 87 | + |
| 88 | + echo "✗ Timeout waiting for platform to become ready" |
| 89 | + exit 1 |
| 90 | + |
| 91 | + - name: Show container logs on failure |
| 92 | + if: failure() |
| 93 | + working-directory: docs/getting-started |
| 94 | + run: | |
| 95 | + docker compose ps |
| 96 | + docker compose logs |
0 commit comments