From 431e3c09d84bc6d04b61b7ab9ac8f67f1ec54a82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Etxaniz=20Errazkin=2C=20I=C3=B1aki?= <inaki.etxaniz@tecnalia.com> Date: Fri, 21 May 2021 16:54:39 +0000 Subject: [PATCH] Ui config for integration --- Dockerfile | 16 ++++++++++++- adapt-config-json.sh | 16 +++++++++++++ docker-entrypoint.sh | 40 +++++++++++++++++++++++++++++++++ src/assets/config-template.json | 35 +++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 adapt-config-json.sh create mode 100755 docker-entrypoint.sh create mode 100644 src/assets/config-template.json diff --git a/Dockerfile b/Dockerfile index 51b987a0..01e2e277 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,20 @@ RUN npm run build -- --prod --aot --base-href $BASE_HREF FROM nginx +COPY docker-entrypoint.sh /docker-entrypoint.sh +COPY adapt-config-json.sh /adapt-config-json.sh +RUN chmod 775 /*.sh + EXPOSE 80 COPY nginx.conf /etc/nginx/conf.d/default.conf -COPY --from=builder /app/dist /usr/share/nginx/html \ No newline at end of file +COPY --from=builder /app/dist /usr/share/nginx/html + +RUN rm /usr/share/nginx/html/assets/config.json + +ENV DASHBOARD_BASE_URL=http://localhost:4200 \ + IDM_BASE_URL=http://localhost:8081 \ + TRAFFIC_PREDICTION_API_BASE_URL=http://localhost:8000/urbanite_traffic \ + BIKE_ANALYSIS_API_BASE_URL=http://localhost:8000/bikeAnalysis \ + IDRA_BASE_URL=http://localhost:8080 \ + DATALET_BASE_URL=http://localhost/deep/deep-components/creator.html + \ No newline at end of file diff --git a/adapt-config-json.sh b/adapt-config-json.sh new file mode 100644 index 00000000..658eaf74 --- /dev/null +++ b/adapt-config-json.sh @@ -0,0 +1,16 @@ +#!/bin/sh +FILE=/usr/share/nginx/html/assets/config.json +if test -f "$FILE"; then + echo "config file already provided" + exit 0 +fi + +TEMPLATE=/usr/share/nginx/html/assets/config-template.json +cp $TEMPLATE $FILE + +sed -i -e "s|__DASHBOARD_BASE_URL__|$DASHBOARD_BASE_URL|g" $FILE +sed -i -e "s|__IDM_BASE_URL__|$IDM_BASE_URL|g" $FILE +sed -i -e "s|__TRAFFIC_PREDICTION_API_BASE_URL__|$TRAFFIC_PREDICTION_API_BASE_URL|g" $FILE +sed -i -e "s|__BIKE_ANALYSIS_API_BASE_URL__|$BIKE_ANALYSIS_API_BASE_URL|g" $FILE +sed -i -e "s|__IDRA_BASE_URL__|$IDRA_BASE_URL|g" $FILE +sed -i -e "s|__DATALET_BASE_URL__|$DATALET_BASE_URL|g" $FILE \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 00000000..cab8f9e9 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# vim:sw=4:ts=4:et + +set -e + +./adapt-config-json.sh + +if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then + exec 3>&1 +else + exec 3>/dev/null +fi + +if [ "$1" = "nginx" -o "$1" = "nginx-debug" ]; then + if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then + echo >&3 "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration" + + echo >&3 "$0: Looking for shell scripts in /docker-entrypoint.d/" + find "/docker-entrypoint.d/" -follow -type f -print | sort -V | while read -r f; do + case "$f" in + *.sh) + if [ -x "$f" ]; then + echo >&3 "$0: Launching $f"; + "$f" + else + # warn on shell scripts without exec bit + echo >&3 "$0: Ignoring $f, not executable"; + fi + ;; + *) echo >&3 "$0: Ignoring $f";; + esac + done + + echo >&3 "$0: Configuration complete; ready for start up" + else + echo >&3 "$0: No files found in /docker-entrypoint.d/, skipping configuration" + fi +fi + +exec "$@" \ No newline at end of file diff --git a/src/assets/config-template.json b/src/assets/config-template.json new file mode 100644 index 00000000..94149d1e --- /dev/null +++ b/src/assets/config-template.json @@ -0,0 +1,35 @@ +{ + "dashboardBaseURL":"__DASHBOARD_BASE_URL__", + "enableAuthentication":true, + "authProfile": "oidc", + "idmBaseURL":"__IDM_BASE_URL__", + "idmRealmName":"urbanite", + "client_id":"urbanite", + "client_secret": "", + "traffic_prediction_api_base_url":"__TRAFFIC_PREDICTION_API_BASE_URL__", + "bike_analysis_api_base_url":"__BIKE_ANALYSIS_API_BASE_URL__", + "idra_base_url":"__IDRA_BASE_URL__", + "idra_portal_base_href":"IdraPortal", + "enable_datalet":true, + "datalet_base_url":"__DATALET_BASE_URL__", + "external-application-cards":[ + { + "url": "http://forum.urbanite-project.eu", + "title": "Virtual SoPoLab", + "subtitle":"The collaboration environment where you can be an active user.", + "avatar": "/assets/images/urbanite_logo.png", + "image": "/assets/images/vsopolab.png", + "description": "The Virtual SoPoLab is a social co-creation environment where needs, ideas and possible solutions can be matched and asked for implementation, in order to support citizens, civil servants and public authorities to work together", + "responsible_partner":"ENG" + }, + { + "url": "https://idra.eng.it", + "title": "Idra", + "subtitle":"Open Data Federation Platform", + "avatar": "/assets/images/idra_D_v6_black.svg", + "image": "/assets/images/userhomepage.png", + "description": "Idra is a web application able to federate existing Open Data Management Systems (ODMS) based on different technologies providing a unique access point to search and discover open datasets coming from heterogeneous sources. Idra uniforms representation of collected open datasets, thanks to the adoption of international standards (DCAT-AP) and provides a set of RESTful APIs to be used by third party applications.", + "responsible_partner":"ENG" + } + ] +} \ No newline at end of file -- GitLab