From 088e040549904b8e891bb6be80b856cc00851429 Mon Sep 17 00:00:00 2001 From: Martin Weise <martin.weise@tuwien.ac.at> Date: Wed, 15 Mar 2023 15:29:13 +0100 Subject: [PATCH] Added healthcheck --- fda-authentication-service/Dockerfile | 10 ++++++++-- fda-authentication-service/healthcheck.sh | 5 +++++ fda-ui/layouts/default.vue | 5 ++--- 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100755 fda-authentication-service/healthcheck.sh diff --git a/fda-authentication-service/Dockerfile b/fda-authentication-service/Dockerfile index f687467497..205f73033b 100644 --- a/fda-authentication-service/Dockerfile +++ b/fda-authentication-service/Dockerfile @@ -29,8 +29,12 @@ COPY --from=binary /usr/bin/curl /usr/bin/curl USER root COPY ./dbrepo-realm.json /opt/keycloak/data/import/dbrepo-realm.json -COPY ./service-register.sh /app/service-register.sh -COPY ./docker-entrypoint.sh /app/docker-entrypoint.sh + +WORKDIR /app + +COPY ./service-register.sh ./service-register.sh +COPY ./docker-entrypoint.sh ./docker-entrypoint.sh +COPY ./healthcheck.sh ./healthcheck.sh ENV METADATA_USERNAME=root ENV METADATA_PASSWORD=dbrepo @@ -45,4 +49,6 @@ ENV KEYCLOAK_IMPORT=/opt/keycloak/data/import/dbrepo-realm.json ENV KEYCLOAK_ADMIN=keycloak ENV KEYCLOAK_ADMIN_PASSWORD=keycloak +HEALTHCHECK --interval=10s --timeout=5s --retries=12 CMD ["bash", "/app/healthcheck.sh"] + ENTRYPOINT ["bash", "/app/docker-entrypoint.sh"] diff --git a/fda-authentication-service/healthcheck.sh b/fda-authentication-service/healthcheck.sh new file mode 100755 index 0000000000..e7842c9278 --- /dev/null +++ b/fda-authentication-service/healthcheck.sh @@ -0,0 +1,5 @@ +#!/bin/bash +HTTP_CODE=$(curl --silent --output /dev/stderr --write-out "%{http_code}" 'http://0.0.0.0:8080/realms/dbrepo') +if test $HTTP_CODE -ne 200; then + exit 1 +fi \ No newline at end of file diff --git a/fda-ui/layouts/default.vue b/fda-ui/layouts/default.vue index 9ba45c2b73..5116d0397f 100644 --- a/fda-ui/layouts/default.vue +++ b/fda-ui/layouts/default.vue @@ -123,7 +123,6 @@ <script> import { isDeveloper } from '@/utils' - export default { name: 'DefaultLayout', data () { @@ -250,7 +249,7 @@ export default { } try { this.loadingUser = true - const res = await this.$axios.put('/api/auth', {}, this.config) + const res = await this.$axios.get('/api/auth/realms/dbrepo/protocol/openid-connect/userinfo', this.keycloakConfig) this.$store.commit('SET_USER', res.data) console.debug('user information', this.user) this.$vuetify.theme.dark = this.user.theme_dark @@ -315,7 +314,7 @@ export default { } try { this.loading = true - const res = await this.$axios.get(`/api/container/${this.$route.params.container_id}/database/${this.$route.params.database_id}/access`, this.silentConfig) + const res = await this.$axios.get(`/api/container/${this.$route.params.container_id}/database/${this.$route.params.database_id}/access`, this.config) this.access = res.data this.$store.commit('SET_ACCESS', res.data) console.debug('access', this.access) -- GitLab