Skip to content

Commit

Permalink
Update to CZ version
Browse files Browse the repository at this point in the history
  • Loading branch information
reihsr committed Dec 3, 2019
1 parent 7c5f8ee commit 32a90db
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 56 deletions.
92 changes: 63 additions & 29 deletions images/openspecimen/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,68 @@
# OpenSpecimen Tomcat Container
#
# VERSION 0.0.2
#

# 0.0.1 : initial creation of image with java version 1.8.0_72-b15 (766.4 MB)
# 0.0.2 : use existing build for tomcat and autobuild gradle container
FROM debian:jessie
ARG DEBIAN_FRONTEND=noninteractive
ARG VERSION="v6.2.x"

FROM tomcat:9.0-jre8
RUN apt-get update \
&& apt-get install -y software-properties-common apt-utils wget gnupg \
apt-transport-https ca-certificates \
&& rm -rf /var/lib/apt/lists/*

MAINTAINER Suyesh Amatya <[email protected]>
# Setup JDK
RUN wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | apt-key add - \
&& add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ \
&& apt-get update \
&& apt install -y adoptopenjdk-8-hotspot

RUN apt-get update \
&& rm -r $CATALINA_HOME/webapps/ROOT \
&& rm -r $CATALINA_HOME/webapps/docs \
&& rm -r $CATALINA_HOME/webapps/examples \
&& mkdir -p /opt/openspecimen/os-data \
&& mkdir -p /opt/openspecimen/os-plugins \
&& ln -s "$CATALINA_HOME" /opt/tomcat \
&& wget http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.31/mysql-connector-java-5.1.31.jar -O /opt/tomcat/lib/mysql-connector-java-5.1.31.jar

# Add admin/admin user
ADD configs/tomcat-users.xml /opt/tomcat/conf/tomcat-users.xml
# Add data source configuration for MySQL root user (username="root" password="openspecimen")
ADD configs/context.xml /opt/tomcat/conf/context.xml
ADD configs/openspecimen.properties /opt/tomcat/conf/openspecimen.properties
# ADD openspecimen war file build with the gradle container with default values
ADD openspecimen.war /opt/dist/openspecimen.war

ADD scripts /opt/scripts
WORKDIR /opt/scripts
RUN chmod a+x *.sh

ENTRYPOINT ["/opt/scripts/entrypoint.sh"]
# Setup tomcat and dependencies
RUN apt-get install -y build-essential libpng-dev \
&& mkdir /opt/tomcat/ \
&& useradd -r -m -U -d /opt/tomcat -s /bin/false tomcat \
&& wget https://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.tar.gz -P /tmp/ \
&& tar xf /tmp/apache-tomcat-9*.tar.gz -C /opt/tomcat \
&& ln -s /opt/tomcat/apache-tomcat-9.0.27 /opt/tomcat/latest \
&& sh -c 'chmod +x /opt/tomcat/latest/bin/*.sh' \
&& chown -R tomcat:tomcat /opt/tomcat/apache-tomcat-9.0.27

ENV GRADLE_HOME="/opt/gradle/gradle-2.0"
ENV PATH="${GRADLE_HOME}/bin:${PATH}"

# Setup build tools
RUN wget http://services.gradle.org/distributions/gradle-2.0-bin.zip -P /tmp \
&& apt-get install -y unzip curl git \
&& unzip -d /opt/gradle /tmp/gradle-*.zip \
&& curl -sL https://deb.nodesource.com/setup_10.x | bash - \
&& apt-get install -y nodejs \
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash \
&& cd /tmp \
&& git clone https://github.com/krishagni/openspecimen.git -b $VERSION \
&& rm /tmp/openspecimen/build.properties \
&& rm /opt/tomcat/latest/conf/context.xml \
&& cd openspecimen/www/ \
&& npm install --loglevel=error \
&& npm install --loglevel=error -g grunt gulp-cli bower \
&& npm audit fix \
&& bower install --allow-root \
&& apt remove -y unzip curl \
&& rm -rf /var/lib/apt/lists/*

# Copy config files
ADD configs/build.properties /tmp/openspecimen/
ADD configs/context.xml /opt/tomcat/latest/conf/
ADD configs/openspecimen.properties /opt/tomcat/latest/conf/

# Build WAR file
RUN cd /tmp/openspecimen \
&& gradle build \
&& cp build/libs/openspecimen.war /opt/tomcat/latest/webapps/ \
&& mkdir -p /opt/tomcat/latest/OpenSpecimen/plugins \
&& chown tomcat:tomcat /opt/tomcat/latest/conf/openspecimen.properties \
&& chown tomcat:tomcat /opt/tomcat/latest/conf/context.xml \
&& wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.18/mysql-connector-java-8.0.18.jar -P /opt/tomcat/latest/lib/ \
&& rm -rf /tmp/openspecimen \
&& apt remove -y git

RUN echo 'export PS1="[\u@openspecimen:\w]# "' >> /root/.bashrc

ENTRYPOINT ["/bin/sh"]
12 changes: 12 additions & 0 deletions images/openspecimen/configs/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
app_home=/opt/tomcat/apache-tomcat-9.0.27/
app_data_dir=/opt/tomcat/apache-tomcat-9.0.27/os-data/
datasource_jndi=jdbc/openspecimen
datasource_type=fresh
database_host=localhost
database_port=3306
database_name=openspecimen
database_username=dbuser
database_password=testpw
plugin_dir=/opt/tomcat/apache-tomcat-9.0.27/OpenSpecimen/plugins/
show_sql=true
deployment_type = fresh
33 changes: 10 additions & 23 deletions images/openspecimen/configs/context.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -18,30 +16,19 @@
<!-- The contents of this file will be loaded for each web application -->
<Context>

<!-- Default set of monitored resources -->
<!-- Default set of monitored resources. If one of these changes, the -->
<!-- web application will be reloaded. -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>


<Resource name="jdbc/openspecimen" driverClassName="com.mysql.cj.jdbc.Driver" url="jdbc:mysql://localhost:3306/openspecimen" auth="Container" maxActive="100" password="testpw" maxWait="10000" username="dbuser" maxIdle="30" type="javax.sql.DataSource"/>

<Environment name="config/openspecimen" value="/opt/tomcat/apache-tomcat-9.0.27/conf/openspecimen.properties" type="java.lang.String"/>

<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->

<!-- Uncomment this to enable Comet connection tacking (provides events
on session expiration as well as webapp lifecycle) -->
<!--
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
-->

<Resource name="jdbc/openspecimen" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="§§username" password="§§password" driverClassName="§§useddatabasedriver"
url="jdbc:§§useddatabasetype://§§host:§§port/§§database"
testOnBorrow="true" validationQuery="select 1 from dual" />

<Environment
name="config/openspecimen"
value="$TOMCAT_DIR/conf/openspecimen.properties"
type="java.lang.String"/>


</Context>
8 changes: 4 additions & 4 deletions images/openspecimen/configs/openspecimen.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ database.type=mysql
datasource.type=fresh

# Absolute path where Tomcat is installed
tomcat.dir=/usr/local/tomcat
tomcat.dir=/opt/tomcat/latest

# Absolute path to OpenSpecimen data directory.
# Best practice: Create a folder in parallel to 'tomcat.dir' with
# the name "openspecimen/data"
app.data_dir=/opt/openspecimen/os-data
app.data_dir=/opt/tomcat/latest/OpenSpecimen

# Absolute path to OpenSpecimen data directory.
# Best practice: Create a folder in parallel to 'tomcat.dir' with
# the name "openspecimen/plugins"
plugin.dir=/opt/openspecimen/os-plugins
plugin.dir=/opt/tomcat/latest/OpenSpecimen/plugins

# Optional. Absolute path of the customised logging configuration file.
# The configuration file should follow log4j configuration rules.
app.log_conf=
app.log_conf=

0 comments on commit 32a90db

Please sign in to comment.