Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev 79 docker workflow #73

Merged
merged 3 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/checkDockerDev.yml
Original file line number Diff line number Diff line change
@@ -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"
69 changes: 69 additions & 0 deletions .github/workflows/checkDockerProd.yml
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class PlaceholderData implements CommandLineRunner {
private final ProjectMemberRepository projectMemberRepository;
private final Random random = new Random(0);

@Value("${CREATE_PLACEHOLDER_DATA}")
@Value("${CREATE_PLACEHOLDER_DATA:false}")
private String CREATE_PLACEHOLDER_DATA;

@Override
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -117,7 +117,7 @@ services:
healthcheck:
test: "pg_isready -U keycloak"
interval: 1s
retries: 30
retries: 50
start_period: 5s
timeout: 3s

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -81,7 +81,7 @@ services:
healthcheck:
test: "pg_isready -U keycloak"
interval: 1s
retries: 30
retries: 50
start_period: 5s
timeout: 3s

Expand Down
Loading