diff --git a/.github/workflows/checkDockerDev.yml b/.github/workflows/checkDockerDev.yml new file mode 100644 index 00000000..2be5c386 --- /dev/null +++ b/.github/workflows/checkDockerDev.yml @@ -0,0 +1,70 @@ +name: Check dockercompose.dev + +on: + push: + branches: [ "main", "devel" ] + pull_request: + branches: [ "main", "devel" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install jq + run: sudo apt-get install -y jq + + - name: Setup useful functions + run: | + rc=/tmp/rcfile + echo "lscontainers() { docker ps -qa | xargs --no-run-if-empty docker inspect; }" >> $rc + echo "asserttrue() { [ \"\$(cat)\" = \"true\" ]; }" >> $rc + echo "checkstatus() { lscontainers | jq -r '.[] | select(.Name == \"/'\"\$1\"'\").State.Status == \"'\"\$2\"'\"'; }" >> $rc + echo "ishealthy() { lscontainers | jq -r '.[] | select(.Name == \"/'\"\$1\"'\").State.Health.Status == \"healthy\"'; }" >> $rc + echo "fatal() { echo \"Check failed: \$@\" 1>&2; exit 1; }" >> $rc + + - name: Boot up containers + run: docker compose -f docker-compose.dev.yml up --build -d + + - name: Wait for transient states to disappear + run: sleep 200 + + - name: Test backend + run: | + source /tmp/rcfile + checkstatus "corn-postgres" "running" | asserttrue || fatal "BackDb" + checkstatus "corn-backend" "running" | asserttrue || fatal "BackSpring" + + - name: Test frontend + run: | + source /tmp/rcfile + checkstatus "corn-frontend" "running" | asserttrue || fatal "FrontNg" + + - name: Test nginx + run: | + source /tmp/rcfile + checkstatus "corn-nginx" "running" | asserttrue || fatal "NginxMain" + + - name: Test keycloak + run: | + source /tmp/rcfile + checkstatus "corn-keycloak" "running" | asserttrue || fatal "KcMain" + ishealthy "corn-keycloak" | asserttrue || fatal "KcMainHealth" + checkstatus "corn-keycloak-postgres" "running" | asserttrue || fatal "KcDb" + ishealthy "corn-keycloak-postgres" | asserttrue || fatal "KcDbHealth" + checkstatus "corn-keycloak-theme" "running" | asserttrue || fatal "KcTheme" + checkstatus "corn-keycloak-initializer" "exited" | asserttrue || fatal "KcInit" + + - name: Test proxies connectivity + run: | + source /tmp/rcfile + curl -qo /dev/null -w "%{http_code}" 'http://localhost:4200/api/fallible' | grep -qP '^(502|503|504).*' || exit 0 && fatal "NginxBack" + curl -qo /dev/null -w "%{http_code}" 'http://localhost:4200/' | grep -qP '^(502|503|504).*' || exit 0 && fatal "NginxFront" + curl -qo /dev/null -w "%{http_code}" 'http://localhost:8081/realms/Corn' | grep -qP '^(502|503|504).*' || exit 0 && fatal "NginxKc" + + - name: Test existence of Corn realm + run: | + source /tmp/rcfile + curl 'http://localhost:8081/realms/Corn/' | jq -r '.error == null' | asserttrue || fatal "CornRealm" diff --git a/.github/workflows/checkDockerProd.yml b/.github/workflows/checkDockerProd.yml new file mode 100644 index 00000000..133c28de --- /dev/null +++ b/.github/workflows/checkDockerProd.yml @@ -0,0 +1,69 @@ +name: Check dockercompose.prod + +on: + push: + branches: [ "main", "devel" ] + pull_request: + branches: [ "main", "devel" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install jq + run: sudo apt-get install -y jq + + - name: Setup useful functions + run: | + rc=/tmp/rcfile + echo "lscontainers() { docker ps -qa | xargs --no-run-if-empty docker inspect; }" >> $rc + echo "asserttrue() { [ \"\$(cat)\" = \"true\" ]; }" >> $rc + echo "checkstatus() { lscontainers | jq -r '.[] | select(.Name == \"/'\"\$1\"'\").State.Status == \"'\"\$2\"'\"'; }" >> $rc + echo "ishealthy() { lscontainers | jq -r '.[] | select(.Name == \"/'\"\$1\"'\").State.Health.Status == \"healthy\"'; }" >> $rc + echo "fatal() { echo \"Check failed: \$@\" 1>&2; exit 1; }" >> $rc + + - name: Boot up containers + run: docker compose -f docker-compose.prod.yml up --build -d + + - name: Wait for transient states to disappear + run: sleep 200 + + - name: Test backend + run: | + source /tmp/rcfile + checkstatus "corn-postgres" "running" | asserttrue || fatal "BackDb" + checkstatus "corn-backend" "running" | asserttrue || fatal "BackSpring" + + - name: Test frontend + run: | + source /tmp/rcfile + checkstatus "corn-frontend" "running" | asserttrue || fatal "FrontNginx" + + - name: Test nginx + run: | + source /tmp/rcfile + checkstatus "corn-nginx" "running" | asserttrue || fatal "NginxMain" + + - name: Test keycloak + run: | + source /tmp/rcfile + checkstatus "corn-keycloak" "running" | asserttrue || fatal "KcMain" + ishealthy "corn-keycloak" | asserttrue || fatal "KcMainHealth" + checkstatus "corn-keycloak-postgres" "running" | asserttrue || fatal "KcDb" + ishealthy "corn-keycloak-postgres" | asserttrue || fatal "KcDbHealth" + checkstatus "corn-keycloak-initializer" "exited" | asserttrue || fatal "KcInit" + + - name: Test proxies connectivity + run: | + source /tmp/rcfile + curl -qo /dev/null -w "%{http_code}" 'http://localhost:4200/api/fallible' | grep -qP '^(502|503|504).*' || exit 0 && fatal "NginxBack" + curl -qo /dev/null -w "%{http_code}" 'http://localhost:4200/' | grep -qP '^(502|503|504).*' || exit 0 && fatal "NginxFront" + curl -qo /dev/null -w "%{http_code}" 'http://localhost:8081/realms/Corn' | grep -qP '^(502|503|504).*' || exit 0 && fatal "NginxKc" + + - name: Test existence of Corn realm + run: | + source /tmp/rcfile + curl 'http://localhost:8081/realms/Corn/' | jq -r '.error == null' | asserttrue || fatal "CornRealm" diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index e7c66a65..ce065daa 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -99,7 +99,7 @@ services: healthcheck: test: "curl -f http://localhost:8080/admin || exit 1" interval: 1s - retries: 30 + retries: 120 start_period: 15s timeout: 5s volumes: @@ -117,7 +117,7 @@ services: healthcheck: test: "pg_isready -U keycloak" interval: 1s - retries: 30 + retries: 50 start_period: 5s timeout: 3s diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index c87ea775..fe938a7e 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -65,7 +65,7 @@ services: healthcheck: test: "curl -f http://localhost:8080/admin || exit 1" interval: 1s - retries: 30 + retries: 120 start_period: 15s timeout: 5s @@ -81,7 +81,7 @@ services: healthcheck: test: "pg_isready -U keycloak" interval: 1s - retries: 30 + retries: 50 start_period: 5s timeout: 3s