diff --git a/Dockerfile b/Dockerfile index 51b987a0851ee3a399193b4d297602abea47d80a..01e2e2775a21f5ce88822b2e39437d3e29b363e0 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 0000000000000000000000000000000000000000..658eaf74401c5bb85d298b1cc4da677d13a3d80d --- /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 0000000000000000000000000000000000000000..cab8f9e960fc239599c80077f54aff6acf05e2be --- /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 0000000000000000000000000000000000000000..94149d1eabafb8bf50b29eefc3480f039434b0b3 --- /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