From 2be44baff1535a275df9737977d0f884a0392576 Mon Sep 17 00:00:00 2001 From: Ralf Stubner Date: Tue, 28 Jun 2022 11:58:48 +0200 Subject: [PATCH] Enable "entrypoint.d" for Connect image Uses the ideas at https://www.camptocamp.com/en/news-events/flexible-docker-entrypoints-scripts as starting point. --- connect/Dockerfile | 5 ++++- .../docker-entrypoint.d/50-activate-license.sh | 18 ++++++++++++++++++ connect/docker-entrypoint.sh | 8 ++++++++ connect/startup.sh | 14 -------------- 4 files changed, 30 insertions(+), 15 deletions(-) create mode 100755 connect/docker-entrypoint.d/50-activate-license.sh create mode 100755 connect/docker-entrypoint.sh mode change 100644 => 100755 connect/startup.sh diff --git a/connect/Dockerfile b/connect/Dockerfile index 95d88ec2..0f23b493 100644 --- a/connect/Dockerfile +++ b/connect/Dockerfile @@ -115,5 +115,8 @@ ENV RSC_LICENSE_SERVER "" COPY rstudio-connect.gcfg /etc/rstudio-connect/rstudio-connect.gcfg VOLUME ["/data"] -ENTRYPOINT ["tini", "--"] +COPY /docker-entrypoint.sh . +COPY /docker-entrypoint.d/* /docker-entrypoint.d/ +ONBUILD COPY /docker-entrypoint.d/* /docker-entrypoint.d/ +ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"] CMD ["/usr/local/bin/startup.sh"] diff --git a/connect/docker-entrypoint.d/50-activate-license.sh b/connect/docker-entrypoint.d/50-activate-license.sh new file mode 100755 index 00000000..d9a51a4c --- /dev/null +++ b/connect/docker-entrypoint.d/50-activate-license.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e +set -x + +# Activate License +RSC_LICENSE_FILE_PATH=${RSC_LICENSE_FILE_PATH:-/etc/rstudio-connect/license.lic} +if ! [ -z "$RSC_LICENSE" ]; then + /opt/rstudio-connect/bin/license-manager activate $RSC_LICENSE +elif ! [ -z "$RSC_LICENSE_SERVER" ]; then + /opt/rstudio-connect/bin/license-manager license-server $RSC_LICENSE_SERVER +elif test -f "$RSC_LICENSE_FILE_PATH"; then + /opt/rstudio-connect/bin/license-manager activate-file $RSC_LICENSE_FILE_PATH +fi + +# ensure these cannot be inherited by child processes +unset RSC_LICENSE +unset RSC_LICENSE_SERVER diff --git a/connect/docker-entrypoint.sh b/connect/docker-entrypoint.sh new file mode 100755 index 00000000..a0bdb9de --- /dev/null +++ b/connect/docker-entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +DIR=/docker-entrypoint.d +if [[ -d "$DIR" ]]; then + /bin/run-parts --verbose "$DIR" +fi + +exec "$@" diff --git a/connect/startup.sh b/connect/startup.sh old mode 100644 new mode 100755 index a691817c..60299ef4 --- a/connect/startup.sh +++ b/connect/startup.sh @@ -10,19 +10,5 @@ deactivate() { } trap deactivate EXIT -# Activate License -RSC_LICENSE_FILE_PATH=${RSC_LICENSE_FILE_PATH:-/etc/rstudio-connect/license.lic} -if ! [ -z "$RSC_LICENSE" ]; then - /opt/rstudio-connect/bin/license-manager activate $RSC_LICENSE -elif ! [ -z "$RSC_LICENSE_SERVER" ]; then - /opt/rstudio-connect/bin/license-manager license-server $RSC_LICENSE_SERVER -elif test -f "$RSC_LICENSE_FILE_PATH"; then - /opt/rstudio-connect/bin/license-manager activate-file $RSC_LICENSE_FILE_PATH -fi - -# ensure these cannot be inherited by child processes -unset RSC_LICENSE -unset RSC_LICENSE_SERVER - # Start RStudio Connect /opt/rstudio-connect/bin/connect --config /etc/rstudio-connect/rstudio-connect.gcfg