Skip to content

Instantly share code, notes, and snippets.

@drjasonharrison-vp-eio
Last active May 27, 2019 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drjasonharrison-vp-eio/c98abcff11009e053618764686771942 to your computer and use it in GitHub Desktop.
Save drjasonharrison-vp-eio/c98abcff11009e053618764686771942 to your computer and use it in GitHub Desktop.
server build dockerfile
# https://github.com/eiodiagnostics/balena-jetson-tx2-experiments
FROM balenalib/jetson-tx2-debian-python:3.6.8-build
LABEL Description="This image is used create a privileged container for Nvidia Jetson TX2 using BalenaOS"
LABEL Vendor="EIO Diagnostics"
LABEL Version="1.0"
LABEL Author="jason@eiodiagnostics.com"
# switch on systemd init system in container -- requires "privileged: true" in docker-compose.yml
ENV INITSYSTEM on
# retry curl after a delay, follow moved files
ARG CURL_OPTS="--max-time 10 --retry 5 --retry-delay 10 --location"
WORKDIR /usr/src/app
COPY . ./
####################################################################
# START SNIPPET FROM; https://github.com/balena-io-library/base-images/blob/master/balena-base-images/openjdk/jetson-tx2/debian/stretch/8-jdk/build/Dockerfile
# Default to UTF-8 file.encoding
ENV LANG C.UTF-8
ENV CA_CERTIFICATES_JAVA_VERSION 20170531+nmu1
RUN ./installJDK.bash
ENV JAVA_HOME /docker-java-home
####################################################################
# END SNIPPET FROM: https://github.com/balena-io-library/base-images/blob/master/balena-base-images/openjdk/jetson-tx2/debian/stretch/8-jdk/build/Dockerfile
####################################################################
####################################################################
# START SNIPPET FROM: https://github.com/open-horizon/cogwerx-jetson-tx2/Dockerfile.cudabase
RUN ./installCuda.bash
ENV LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu/tegra${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
ENV PATH="${PATH}:/usr/local/cuda/bin"
####################################################################
# END SNIPPET FROM: https://github.com/open-horizon/cogwerx-jetson-tx2
####################################################################
###################################################################
#
# Install tomcat8
#
# Tomcat warns that we need to define default locale
RUN mkdir -p /etc/default \
&& echo "LANG=en_CA.UTF-8" > /etc/default/locale
ENV CATALINA_HOME=/var/lib/tomcat8
ENV PATH=$CATALINA_HOME/bin:$PATH
WORKDIR $CATALINA_HOME
RUN apt-get update && apt-get install -y --no-install-recommends \
tomcat8 \
tomcat8-admin \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Tomcat8: see /etc/init.d/tomcat8 for systemctl startup scrip for tomcat8
###################################################################
#
# Install Python3 and Tensorflow
#
# For Nvidia Jetson see
# https://devtalk.nvidia.com/default/topic/1038957/jetson-tx2/tensorflow-for-jetson-tx2-/
# Python 3.6+JetPack4.2
# pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 \
# tensorflow-gpu==1.13.1+nv19.5 --user
RUN apt-get update && apt-get install -y --no-install-recommends \
python3-dev \
libhdf5-serial-dev \
hdf5-tools \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 \
tensorflow-gpu==1.13.1+nv19.5 --user
####################################################################
# barnserv
####################################################################
# Issue #903: for whatever reason, these symbolic links point to missing files
RUN sudo unlink /usr/share/tomcat8/lib/commons-dbcp.jar
RUN sudo unlink /usr/share/tomcat8/lib/commons-pool.jar
# Issue #875: increase heap space for applications running within Tomcat.
# See http://www.mkyong.com/tomcat/tomcat-javalangoutofmemoryerror-permgen-space/
#
# Also turn on log4j debug in catalina.out
RUN mkdir -p $CATALINA_HOME/bin \
&& echo -n "export JAVA_OPTS=\"-Dfile.encoding=UTF-8 -Xms128m -Xmx1024m -Dlog4j.debug\"\n" >> $CATALINA_HOME/bin/setenv.sh
# TODO specify log4j2 configuration file:
# -Dlog4j.configurationFile=file:"<FILE_PATH>"
WORKDIR /usr/src/app
ENV TOMCAT_RSC=./Tomcat/
# setup tomcat configuration
RUN rm -rf ${CATALINA_HOME}/webapps/ROOT \
&& mkdir -p ${CATALINA_HOME}/jcache \
&& mkdir -p ${CATALINA_HOME}/jcache/imagerecord \
&& mkdir -p ${CATALINA_HOME}/bin
COPY ${TOMCAT_RSC}/web.xml ${CATALINA_HOME}/conf/web.xml
COPY ${TOMCAT_RSC}/catalina.properties ${CATALINA_HOME}/conf/catalina.properties
COPY ${TOMCAT_RSC}/logging.properties ${CATALINA_HOME}/conf/logging.properties
COPY ${TOMCAT_RSC}/server.xml ${CATALINA_HOME}/conf/server.xml
COPY ${TOMCAT_RSC}/ROOT ${CATALINA_HOME}/webapps/
COPY ${TOMCAT_RSC}/web_resource/ ${CATALINA_HOME}/jcache/
RUN chown -R tomcat8 ${CATALINA_HOME}
# TODO: JH can probably remove this, (a) should be updated by pushToBalena, (b) unneeded unless we build
# on device, (c) can probably extract jars from server.war and install them on device.
# copy EIO maven projects
#ENV MAVEN_REPO_HOME="/root/m2/repository"
#RUN mkdir -p ${MAVEN_REPO_HOME}/com \
# && cp -R /usr/src/app/source/m2-repository/com ${MAVEN_REPO_HOME}
# install the barnserver
RUN cp /usr/src/app/source/server.war ${CATALINA_HOME}/webapps/server.war
ENV PATH="${PATH}:/usr/local/cuda/bin"
ENV BASE_RB="/usr/src/app/source/scripts/base"
# JH TODO: I don't think this is necessary but let's keep until that is determined
RUN chown -R tomcat8 /home
# switch back to our app home directory when the container starts
WORKDIR /usr/src/app
# && ngrok service install -config /usr/src/app/ngrok.yml
RUN printf "alias start='systemctl start'\nalias stop='systemctl stop'\n" >> /root/.bashrc
WORKDIR /home/ubuntu/data/tomcat/
CMD ["/usr/src/app/runCommand.bash"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment