Browse Source

Updating for versions of labkey beyond 22

Andrej Studen 1 week ago
parent
commit
acea3bc5bd

+ 16 - 6
bin/env.sh.sample

@@ -1,10 +1,20 @@
 export NETWORK=labkey_network;
 export POSTGRES_DIR=$HOME/postgresql/data;
-export LABKEY_DIR=$HOME/labkey
-export TOMCAT_DIR=$HOME/tomcat8
-export COMPOSE=$HOME/config/labkey-compose.yaml
-export DOCKERCOMPOSE=$HOME/.docker/cli-plugins/docker-compose
+export LABKEY_SRC=$HOME/labkeySrc
+export LABKEY_STATIC=$HOME/labkeyStatic
+export LABKEY_HOME=$HOME/labkeyBase
+export LABKEY_TMP=${LABKEY_HOME}/labkey-tmp
+export LABKEY_LOGS=${LABKEY_HOME}/logs
+export COMPOSE=$HOME/config/labkey-compose24.11.yaml
+#export DOCKERCOMPOSE=$HOME/.docker/cli-plugins/docker-compose
+DOCKERCOMPOSE=/usr/local/bin/docker-compose
 export PGPASS=somethingSecret
 #other variables
-export USER_ID=id_of_labkey_user
-export GROUP_ID=group_id_of_labkey_user
+export USER_ID=$(id -u labkey)
+export GROUP_ID=$(id -g labkey)
+#java for docker container
+JAVA_FLAGS_JAR_OPS="-Dorg.apache.catalina.startup.EXIT_ON_INIT_FAILURE=true -DterminateOnStartupFailure=true"
+JAVA_REFLECTION_JAR_OPS="--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED"
+J_FLAGS="-Xms2G -Xmx2G -XX:+HeapDumpOnOutOfMemoryError -Djava.io.tmpdir=/home/labkey/labkey-tmp"
+J_FLAGS="${J_FLAGS} ${JAVA_FLAGS_JAR_OPS} ${JAVA_REFLECTION_JAR_OPS}"
+export J_FLAGS=${J_FLAGS}

+ 32 - 33
bin/installLabkey.sh

@@ -1,58 +1,57 @@
 #!/bin/bash
 
-LABKEY=LabKey22.3.2-3-community
+. $(dirname $0)/env.sh
+
+LABKEY=LabKey24.11.11-14-community
 
 if [ $# -gt 0 ] ; 
 then
 	case $1 in
-	18.1)
-		LABKEY=LabKey18.1-57017.17-professional-bin;;
-	18.3)
-		LABKEY=LabKey18.3.3-62784.7-community-bin;;
-	20.7)
-		LABKEY=LabKey20.7.8-66016.22-community-bin;;
-	21.1)
-		LABKEY=LabKey21.11.10-11-community;;
-	22.3)        
-        	LABKEY=LabKey22.3.2-3-community;;
+	24.11)        
+    	LABKEY=LabKey24.11.11-14-community;;
 	esac;
 
 fi;
 
 echo "Using $LABKEY";
 
-SFW_SRC=$HOME/software/packages/$LABKEY.tar.gz
-LABKEY_BASE=$HOME/labkey
-SFW_DIR=$HOME/software/src
+#config/application.settings are generic/complex enough that is part of the git container 
+#and is not overwritten from source
+#one can find template in ${TGZ_PATH}, ${LABKEY}/config/application.settings (to copy it to temp, use)
+#tar xvzf ${TGZ_PATH} -C ~/temp --strip=2 ${LABKEY}/config/application.settings
+
+#set database
+if [ ! -d ${POSTGRES_DIR} ] ; then
+   mkdir ${POSTGRES_DIR};
+fi;
+
+#set labkey-home
 
-if [ ! -d ${SFW_DIR} ] ; 
+if [ ! -d ${LABKEY_HOME} ] ; 
 then
-	mkdir ${SFW_DIR};
+   mkdir ${LABKEY_HOME};
 fi;
 
-if [ ! -d $LABKEY_BASE ] ; 
+#link source jar
+if [ -f ${LABKEY_HOME}/labkeyServer.jar ] ; 
 then
-	mkdir $LABKEY_BASE;
+   rm ${LABKEY_HOME}/labkeyServer.jar;
 fi;
 
-CFG_DIR=$HOME/config
-LABKEY_DIR=$SFW_DIR/$LABKEY;
+TGZ_PATH=$HOME/software/packages/$LABKEY.tar.gz
+tar xvzf ${TGZ_PATH} -C ${LABKEY_HOME} --strip=1 ${LABKEY}/labkeyServer.jar
 
+#create helper directories
 
-LINK_DIRS=("tomcat-lib" "labkeywebapp" "modules" "pipeline-lib")
+if [ ! -d ${LABKEY_TMP} ] ; 
+then
+   mkdir ${LABKEY_TMP};
+fi;
 
-if [ ! -d ${LABKEY_DIR} ] ; then
-  	cd ${SFW_DIR};
-  	tar xvzf ${SFW_SRC};
-  	echo "Using distribution in ${LABKEY_DIR}";
+if [ ! -d ${LABKEY_LOGS} ] ; 
+then
+   mkdir ${LABKEY_LOGS};
 fi;
 
-for d in ${LINK_DIRS[@]} ; 
-do
-	  if [ -L ${LABKEY_BASE}/$d ] ;
-	  then
-		  rm ${LABKEY_BASE}/$d;
-	  fi;
-	  ln -s ${LABKEY_DIR}/$d ${LABKEY_BASE}/$d;
-done;
 
+exit 0;

+ 58 - 0
bin/installLabkeyOld.sh

@@ -0,0 +1,58 @@
+#!/bin/bash
+
+LABKEY=LabKey22.3.2-3-community
+
+if [ $# -gt 0 ] ; 
+then
+	case $1 in
+	18.1)
+		LABKEY=LabKey18.1-57017.17-professional-bin;;
+	18.3)
+		LABKEY=LabKey18.3.3-62784.7-community-bin;;
+	20.7)
+		LABKEY=LabKey20.7.8-66016.22-community-bin;;
+	21.1)
+		LABKEY=LabKey21.11.10-11-community;;
+	22.3)        
+    	LABKEY=LabKey22.3.2-3-community;;
+	esac;
+
+fi;
+
+echo "Using $LABKEY";
+
+SFW_SRC=$HOME/software/packages/$LABKEY.tar.gz
+LABKEY_BASE=$HOME/labkey
+SFW_DIR=$HOME/software/src
+
+if [ ! -d ${SFW_DIR} ] ; 
+then
+	mkdir ${SFW_DIR};
+fi;
+
+if [ ! -d $LABKEY_BASE ] ; 
+then
+	mkdir $LABKEY_BASE;
+fi;
+
+CFG_DIR=$HOME/config
+LABKEY_DIR=$SFW_DIR/$LABKEY;
+
+
+LINK_DIRS=("tomcat-lib" "labkeywebapp" "modules" "pipeline-lib")
+
+if [ ! -d ${LABKEY_DIR} ] ; then
+  	cd ${SFW_DIR};
+  	tar xvzf ${SFW_SRC};
+  	echo "Using distribution in ${LABKEY_DIR}";
+fi;
+
+for d in ${LINK_DIRS[@]} ; 
+do
+	  if [ -L ${LABKEY_BASE}/$d ] ;
+	  then
+		  rm ${LABKEY_BASE}/$d;
+	  fi;
+	  ln -s ${LABKEY_DIR}/$d ${LABKEY_BASE}/$d;
+done;
+

+ 4 - 1
config/db/Dockerfile

@@ -1,4 +1,4 @@
-FROM postgres:14.2
+FROM postgres:17.2
 
 ARG USER_ID
 ARG GROUP_ID
@@ -10,6 +10,9 @@ RUN adduser --gecos 'LabKey' --uid ${USER_ID} --gid ${GROUP_ID} --disabled-passw
 RUN echo 'labkey ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
 RUN usermod -G root,sudo labkey
 
+RUN chown -R labkey:labkey /var/lib/postgresql \
+   && chown -R labkey:labkey /var/run/postgresql
+
 USER labkey
 
 LABEL "name"="postgresqlX"

+ 47 - 0
config/labkey-compose24.11.yaml

@@ -0,0 +1,47 @@
+services:
+
+  labkey-db:
+#    image: postgres:14.2
+#
+    build:
+            context: ./db
+            args:
+                    USER_ID: ${USER_ID}
+                    GROUP_ID: ${GROUP_ID}
+
+    volumes: 
+       - ${POSTGRES_DIR}:/var/lib/postgresql/data
+    environment:
+       - POSTGRES_USER=postgres
+       - POSTGRES_PASSWORD=$PGPASS
+       - POSTGRES_DB=labkey
+    ports:
+       - 5432
+
+  labkey-web:
+    depends_on:
+        - labkey-db
+    #image: tomcat:9-jdk17-temurin
+    #
+
+    build: 
+            context: ./web
+            args:
+                    USER_ID: ${USER_ID}
+                    GROUP_ID: ${GROUP_ID}
+                    JAVA_FLAGS: ${J_FLAGS}
+
+    volumes:
+      - ${LABKEY_HOME}:/home/labkey
+      #- ${TOMCAT_DIR}/conf/key.pem:/usr/local/tomcat/conf/key.pem
+      #- ${TOMCAT_DIR}/conf/cert.pem:/usr/local/tomcat/conf/cert.pem
+      #- ${TOMCAT_DIR}/conf/ca-chain.pem:/usr/local/tomcat/conf/ca-chain.pem
+    ports:
+      - 8081:8080
+      - 8444:8443
+    
+
+networks:
+   default:
+     name: labkey_network
+     external: true

+ 15 - 7
config/web/Dockerfile

@@ -1,17 +1,23 @@
-FROM tomcat:9-jdk17-temurin-focal
+FROM eclipse-temurin:17.0.14_7-jdk-jammy
+#possible eclipse-temurin:17.0.13_11-jdk-jammy
+#possible eclipse-temurin:17-jdk-jammy
 
 ARG USER_ID
 ARG GROUP_ID
+ARG LABKEY_HOME
+ARG JAVA_FLAGS
 
 RUN apt-get update && apt-get install -y sudo;
 
 RUN addgroup --gid ${GROUP_ID} labkey
+#assume /home/labkey as home directory for labkey
 RUN adduser --gecos 'LabKey' --uid ${USER_ID} --gid ${GROUP_ID} --disabled-password labkey 
 RUN echo 'labkey ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
 RUN usermod -G root,sudo labkey
 
 USER labkey
 
+#replace focal with jammy in deb
 ARG RKEY=https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc 
 ARG GPGKEY=/etc/apt/trusted.gpg.d/cran_ubuntu_key.asc 
 RUN sudo apt-get update && sudo apt-get install -y \
@@ -21,14 +27,16 @@ RUN sudo apt-get update && sudo apt-get install -y \
 		ca-certificates \
 		software-properties-common \
 	&& wget -qO- $RKEY | sudo tee -a $GPGKEY\
-	&& sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/"\
+	&& sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/"\
 	&& sudo apt-get update --fix-missing\
 	&& sudo apt-get install -y r-base \
 	&& sudo rm -rf /var/lib/apt/lists/*
 
-RUN sudo mkdir /usr/local/labkey \
-   && sudo chown -R labkey:labkey /usr/local/tomcat \
-   && sudo chown -R labkey:labkey /usr/local/labkey
-#USER root
+#RUN sudo systemctl daemon-reload 
 
-LABEL "name"="tomcatR"
+WORKDIR /home/labkey
+ENV LABKEY_HOME=/home/labkey JAVA_FLAGS=${JAVA_FLAGS}
+CMD java ${JAVA_FLAGS} -jar /home/labkey/labkeyServer.jar
+#CMD echo ${JAVA_FLAGS}
+
+LABEL "name"="eclipse-temurinR"

+ 109 - 0
labkeyBase/config/application.properties.sample

@@ -0,0 +1,109 @@
+## Configure your application using the properties below. Not all properties are needed.
+##   Uncomment lines to activate them. Substitute values shown with @@ markers.
+##   Learn more here: https://www.labkey.org/Documentation/wiki-page.view?name=applicationProperties
+
+####################################################################################
+## Database connections and encryption key.
+####################################################################################
+
+## Primary database configuration
+##   All deployments need a "labkeyDataSource" as their primary database.
+context.resources.jdbc.labkeyDataSource.type=javax.sql.DataSource
+context.resources.jdbc.labkeyDataSource.driverClassName=org.postgresql.Driver
+context.resources.jdbc.labkeyDataSource.url=jdbc:postgresql://labkey-db:5432/labkey
+context.resources.jdbc.labkeyDataSource.username=postgres
+context.resources.jdbc.labkeyDataSource.password=somethingSecret
+context.resources.jdbc.labkeyDataSource.maxTotal=50
+context.resources.jdbc.labkeyDataSource.maxIdle=10
+context.resources.jdbc.labkeyDataSource.maxWaitMillis=120000
+context.resources.jdbc.labkeyDataSource.accessToUnderlyingConnectionAllowed=true
+context.resources.jdbc.labkeyDataSource.validationQuery=SELECT 1
+#context.resources.jdbc.labkeyDataSource.logQueries=true
+#context.resources.jdbc.labkeyDataSource.displayName=Alternate Display Name
+
+## Add external data sources using a prefix containing a unique extraDataSourceName.
+##   i.e. context.resources.jdbc.@@extraDataSourceName@@.<necessary property names>
+##   At a minimum, they must include these required properties: driverClassName, url, username, and password
+#context.resources.jdbc.@@extraDataSourceName@@.driverClassName=org.postgresql.Driver
+#context.resources.jdbc.@@extraDataSourceName@@.url=jdbc:postgresql://localhost:5432/extraDataSource
+#context.resources.jdbc.@@extraDataSourceName@@.username=@@username@@
+#context.resources.jdbc.@@extraDataSourceName@@.password=@@password@@
+
+context.encryptionKey=tai3PhahfuSi7Gu8ohsh0Ae2ohQuoozi
+
+####################################################################################
+## Port and HTTP/HTTPS Settings
+####################################################################################
+
+## Set the primary port.
+##   Required. If using HTTPS, this will typically be 443.
+##   If using HTTP, this will typically be 80
+server.port=8080
+
+## To use HTTPS, update and uncomment the necessary properties below.
+##   Learn more here: https://www.labkey.org/Documentation/wiki-page.view?name=labkeyssl
+#server.ssl.enabled=true
+#server.ssl.enabled-protocols=TLSv1.3,TLSv1.2
+#server.ssl.protocol=TLS
+#server.ssl.key-alias=tomcat
+#server.ssl.key-store=@@keyStore@@
+#server.ssl.key-store-password=@@keyStorePassword@@
+#server.ssl.key-store-type=PKCS12
+#server.ssl.ciphers=HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!kRSA:!EDH:!DHE:!DH:!CAMELLIA:!ARIA:!AESCCM:!SHA:!CHACHA20
+
+server.error.include-stacktrace=always
+server.error.include-message=always
+
+## HTTP-only port for servers that need to handle both HTTPS (configure via server.port and server.ssl above) and HTTP
+##   This must not be the same as the server.port set above.
+#context.httpPort=80
+
+## We strongly recommend deploying LabKey at the root context path (e.g. http://localhost:8080)
+## If your previous configuration file was named "ROOT.xml", you were already deployed at the root.
+## If you previously used a different context path, such as "/labkey" (i.e. with a configuration
+## file named "labkey.xml"), set a legacy context path for backwards compatibility.
+## Previous URLs, GETs, etc. will be redirected or handled server-side via a servlet forward.
+#context.legacyContextPath=/labkey
+
+## We do not recommend deploying to a non-root context path (e.g. http://localhost:8080/labkey)
+## If you do set this property, do not set a legacyContextPath.
+#context.contextPath=/labkey
+
+####################################################################################
+## SMTP configuration
+## Learn more here: https://www.labkey.org/Documentation/wiki-page.view?name=SMTPsettings
+####################################################################################
+mail.smtpHost=localhost
+mail.smtpPort=25
+mail.smtpUser=Anonymous
+#mail.smtpFrom=@@smtpFrom@@
+#mail.smtpPassword=@@smtpPassword@@
+#mail.smtpStartTlsEnable=@@smtpStartTlsEnable@@
+#mail.smtpSocketFactoryClass=@@smtpSocketFactoryClass@@
+#mail.smtpAuth=@@smtpAuth@@
+
+####################################################################################
+## Optional properties needed in some situations.
+####################################################################################
+
+## HTTP session timeout for users. Leave commented out for the default of 30 minutes.
+## Uncomment and set a different value if required.
+#server.servlet.session.timeout=30m
+
+## Use a custom logging configuration
+#logging.config=labkeywebapp/WEB-INF/classes/log4j2.xml
+
+## Enable tomcat access log
+#server.tomcat.accesslog.enabled=true
+#server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %S %I "%{Referrer}i" "%{User-Agent}i" %{LABKEY.username}s
+
+#context.requiredModules=
+#context.pipelineConfig=@@/path/to/pipeline/config/dir@@
+#context.serverGUID=
+#context.bypass2FA=true
+#context.workDirLocation=@@/path/to/desired/workDir@@
+
+## Other webapps to be deployed, most commonly to deliver a set of static files. The context path to deploy into is the
+## property name after the "context.additionalWebapps." prefix, and the value is the location of the webapp on disk
+#context.additionalWebapps.firstContextPath=@@/my/webapp/path@@
+#context.additionalWebapps.secondContextPath=@@/my/other/webapp/path@@