Initial support to workspace mount. #14

Merged
andrea.dellamico merged 1 commits from andrea.dellamico/docker-jenkins-integration-test:master into master 2022-04-01 23:46:25 +02:00
3 changed files with 75 additions and 3 deletions
Showing only changes of commit b2a4c0ec51 - Show all commits

24
06-fuse-logback.xml Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/var/log/workspace-lib/fuse-workspace.log</file>
<append>true</append>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{0}: %msg%n
</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>./var/log/workspace-lib/fuse-workspace.log%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
<maxFileSize>10MB</maxFileSize>
<totalSizeCap>100MB</totalSizeCap>
</rollingPolicy>
</appender>
<logger name="org.gcube.data.access.storagehub.fs" level="WARN" />
<logger name="org.gcube" level="WARN" />
<root level="WARN">
<appender-ref ref="FILE" />
</root>
</configuration>

43
06_workspace_mount.sh Normal file
View File

@ -0,0 +1,43 @@
#!/usr/bin/with-contenv bash
echo "Manage the user's workspace"
workspace_dir='/workspace'
workspace_logdir='/var/log/workspace-lib'
workspace_libdir='/opt/workspace-lib'
workspace_fuse_jar="$workspace_libdir/fuse-workspace.jar"
_decode_base64_url() {
local len=$((${#1} % 4))
local result="$1"
if [ $len -eq 2 ]; then result="$1"'=='
elif [ $len -eq 3 ]; then result="$1"'='
fi
echo "$result" | tr '_-' '/+' | base64 -d
}
# $1 => JWT to decode
# $2 => either 1 for header or 2 for body (default is 2)
decode_jwt() { _decode_base64_url $(echo -n $1 | cut -d "." -f ${2:-2}) | jq .; }
[[ ! -d "$workspace_dir" ]] || [[ -z `ls -A "$workspace_dir"` ]] || mv $workspace_dir ${workspace_dir}.old
mkdir -p $workspace_dir
chown ${USER}:${USER} $workspace_dir
chown -R ${USER}:${USER} $workspace_logdir
_retval=
/bin/rm /home/${USER}/workspace
_retval=$?
if [ $_retval -ne 0 ]; then
echo "The user has a directory named 'workspace' inside their home directory"
echo "Not starting the workspace mount"
exit
else
ln -s /home/${USER}/workspace $workspace_dir
fi
echo "Mount the workspace"
su - "$USER" -c "/usr/bin/java -cp .:${workspace_dir}:${workspace_logdir}/ -Dlogback.configurationFile=${workspace_logdir}/logback.xml -jar $workspace_fuse_jar $SHINYPROXY_OIDC_ACCESS_TOKEN $workspace_dir" >/dev/null 2>&1 &
exit ?$

View File

@ -12,12 +12,10 @@ ENV DEFAULT_USER=rstudio
ENV PANDOC_VERSION=default ENV PANDOC_VERSION=default
ENV PATH=/usr/lib/rstudio-server/bin:$PATH ENV PATH=/usr/lib/rstudio-server/bin:$PATH
RUN /rocker_scripts/install_rstudio.sh RUN /rocker_scripts/install_rstudio.sh
RUN /rocker_scripts/install_pandoc.sh RUN /rocker_scripts/install_pandoc.sh
# Add the mountpoint for the workspace RUN apt-get update && apt-get install -y fuse zip jq
RUN mkdir /workspace
# This part comes from https://github.com/openanalytics/shinyproxy-rstudio-ide-demo/blob/master/Dockerfile # This part comes from https://github.com/openanalytics/shinyproxy-rstudio-ide-demo/blob/master/Dockerfile
RUN echo "www-frame-origin=same" >> /etc/rstudio/disable_auth_rserver.conf RUN echo "www-frame-origin=same" >> /etc/rstudio/disable_auth_rserver.conf
@ -32,6 +30,13 @@ ADD 03_setup_root_path.sh /etc/cont-init.d/03_setup_root_path
#ADD 04_copy_env.sh /etc/cont-init.d/04_copy_env #ADD 04_copy_env.sh /etc/cont-init.d/04_copy_env
ADD 05_setup_rsession_parameters.sh /etc/cont-init.d/05_setup_rsession_parameters ADD 05_setup_rsession_parameters.sh /etc/cont-init.d/05_setup_rsession_parameters
# Prepare the workspace environment
RUN mkdir -p /opt/workspace-lib
RUN mkdir /var/log/workspace-lib
ADD https://maven.d4science.org/nexus/content/repositories/gcube-snapshots/org/gcube/data-access/sh-fuse-integration/2.0.0-SNAPSHOT/sh-fuse-integration-2.0.0-20211005.090627-1-jar-with-dependencies.jar /workspace-lib/fuse-workspace.jar
ADD 06_workspace_mount.sh /etc/cont-init.d/06_workspace_mount
ADD 06-fuse-logback.xml /workspace-lib/logback.xml
EXPOSE 8787 EXPOSE 8787
CMD ["/init"] CMD ["/init"]