Skip to content

Commit

Permalink
docker: add light image
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Alexandre Meyer <[email protected]>
  • Loading branch information
pierre committed Aug 28, 2019
1 parent 211453e commit 7e9de44
Show file tree
Hide file tree
Showing 85 changed files with 190 additions and 6 deletions.
5 changes: 4 additions & 1 deletion ansible/templates/tomcat/conf/setenv.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ CATALINA_OPTS="-server
{% endif %}
-XX:SurvivorRatio={{ jvm_survivor_ratio }}
-XX:+DisableExplicitGC
{% if not lookup('env', 'TOMCAT_DISABLE_GC_LOGGING') %}
-Xloggc:{{ catalina_base }}/logs/gc.log
-XX:+PrintGCApplicationConcurrentTime
-XX:+PrintGCApplicationStoppedTime
Expand All @@ -48,7 +49,9 @@ CATALINA_OPTS="-server
-XX:+PrintTenuringDistribution
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=14
-XX:GCLogFileSize=100M"
-XX:GCLogFileSize=100M
{% endif %}
"

# Java Properties
export CATALINA_OPTS="$CATALINA_OPTS
Expand Down
46 changes: 41 additions & 5 deletions docker/templates/killbill/light/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,45 @@
FROM killbill/killbill:0.20.11
MAINTAINER Kill Bill core team <[email protected]>

RUN kpm uninstall kpm --destination=/var/lib/killbill/bundles
# Install envsubst (see killbill.sh)
USER root
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get install -y \
gettext-base && \
rm -rf /var/lib/apt/lists/*
ENV DEBIAN_FRONTEND teletype
USER tomcat

ENV TOMCAT_JAVA_XMS 1024m
ENV TOMCAT_JAVA_XMX 1792m
ENV TOMCAT_JAVA_NEW_SIZE 100m
ENV TOMCAT_JAVA_MAX_NEW_SIZE 768m
# Pre-expand the WAR
RUN cd $TOMCAT_HOME/webapps && \
mkdir ROOT && \
cd ROOT && \
jar -xvf ../ROOT.war && \
touch -r ../ROOT.war META-INF/war-tracker && \
cd - && \
rm -f ROOT.war && \
cd -

# Custom libraries
COPY lib/*.jar $TOMCAT_HOME/webapps/ROOT/WEB-INF/lib/
# Hack for now...
RUN cd $TOMCAT_HOME/webapps && \
rm -f animal-sniffer-annotations-1.14.jar annotations-3.0.1u2.jar asm-5.0.3.jar commons-codec-1.9.jar commons-lang3-3.2.1.jar error_prone_annotations-2.1.3.jar google-api-services-sqladmin-v1beta4-rev20190510-1.28.0.jar j2objc-annotations-1.1.jar jackson-core-2.9.6.jar && \
cd -

# Disable Ansible (requires /dev/shm)
ENV KPM_INSTALL_CMD /bin/true

# No JRuby plugin and no OSGI bundle, to keep memory usage low
RUN kpm uninstall kpm --destination=$KILLBILL_INSTALL_DIR/bundles
RUN rm -f $KILLBILL_INSTALL_DIR/bundles/platform/*

# Note that classic configuration via environment variables won't work since Ansible isn't invoked
COPY context.xml $TOMCAT_HOME/conf/context.xml
COPY server.xml $TOMCAT_HOME/conf/server.xml
COPY setenv.sh $TOMCAT_HOME/bin/setenv.sh
COPY webapp-context.xml $TOMCAT_HOME/webapps/ROOT/META-INF/context.xml
COPY logback.xml $KILLBILL_INSTALL_DIR/logback.xml
COPY killbill.properties.template $KILLBILL_INSTALL_DIR/killbill.properties.template
COPY killbill.sh $KILLBILL_INSTALL_DIR
6 changes: 6 additions & 0 deletions docker/templates/killbill/light/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Kill Bill light

Kill Bill light is suitable for serverless deployments such as Google Cloud Run:

* Memory usage low
* No `/dev/shm` requirement
3 changes: 3 additions & 0 deletions docker/templates/killbill/light/context.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<Context unloadDelay="31000" docBase="/var/lib/tomcat/webapps/">
</Context>
16 changes: 16 additions & 0 deletions docker/templates/killbill/light/killbill.properties.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
org.killbill.persistent.bus.external.inMemory=true
org.killbill.persistent.bus.main.inMemory=true
org.killbill.security.shiroNbHashIterations=1
org.killbill.jaxrs.threads.pool.nb=5
org.killbill.payment.plugin.threads.nb=1
org.killbill.billing.osgi.bundles.jruby.conf.dir=/var/lib/killbill/config
org.killbill.osgi.bundle.install.dir=/var/lib/killbill/bundles
org.killbill.server.baseUrl=http://localhost:8080
org.killbill.billing.osgi.dao.user=$KILLBILL_DAO_USER
org.killbill.billing.osgi.dao.password=$KILLBILL_DAO_PASSWORD
org.killbill.billing.osgi.dao.url=$KILLBILL_DAO_URL
org.killbill.dao.user=$KILLBILL_DAO_USER
org.killbill.dao.password=$KILLBILL_DAO_PASSWORD
org.killbill.dao.url=$KILLBILL_DAO_URL
org.killbill.dao.maxActive=10
org.killbill.billing.osgi.dao.maxActive=10
9 changes: 9 additions & 0 deletions docker/templates/killbill/light/killbill.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

export KILLBILL_DAO_USER=${KILLBILL_DAO_USER:-killbill}
export KILLBILL_DAO_PASSWORD=${KILLBILL_DAO_PASSWORD:-killbill}
export KILLBILL_DAO_URL=${KILLBILL_DAO_URL:-jdbc:h2:mem:killbill}

envsubst < $KILLBILL_INSTALL_DIR/killbill.properties.template > $KILLBILL_INSTALL_DIR/killbill.properties

exec /usr/share/tomcat/bin/catalina.sh run
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docker/templates/killbill/light/lib/asm-7.1.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions docker/templates/killbill/light/lib/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mvn dependency:copy-dependencies -DoutputDirectory=.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docker/templates/killbill/light/lib/gson-2.7.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
19 changes: 19 additions & 0 deletions docker/templates/killbill/light/lib/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.kill-bill.docker</groupId>
<artifactId>killbill-light</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory-connector-j-8</artifactId>
<version>1.0.14</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-logging-logback</artifactId>
<version>0.106.0-alpha</version>
</dependency>
</dependencies>
</project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
17 changes: 17 additions & 0 deletions docker/templates/killbill/light/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<configuration scan="false">
<appender name="CLOUD" class="com.google.cloud.logging.logback.LoggingAppender">
<log>killbill.log</log>
<flushLevel>WARN</flushLevel>
</appender>

<!-- Silence verbose loggers -->
<logger name="com.dmurph" level="OFF"/>
<logger name="jdbc" level="OFF"/>
<logger name="org.jooq.Constants" level="OFF"/>
<logger name="org.eclipse" level="WARN"/>
<logger name="org.killbill.commons.jdbi.guice.DBIProvider" level="OFF"/>

<root level="INFO">
<appender-ref ref="CLOUD" />
</root>
</configuration>
36 changes: 36 additions & 0 deletions docker/templates/killbill/light/server.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!-- APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

<Service name="Catalina">
<Executor name="tomcatThreadPool"
namePrefix="catalina-exec-"
maxThreads="20"
maxIdleTime="30000"
minSpareThreads="4"
prestartminSpareThreads="true" />

<Connector executor="tomcatThreadPool"
port="8080"
protocol="HTTP/1.1"
connectionTimeout="20000" />

<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost"
appBase="webapps"
unpackWARs="true"
autoDeploy="false">

<Valve className="org.apache.catalina.valves.RemoteIpValve"
protocolHeader="x-forwarded-proto"
portHeader="x-forwarded-port" />
</Host>
</Engine>
</Service>
</Server>
33 changes: 33 additions & 0 deletions docker/templates/killbill/light/setenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export JAVA_HOME=${JAVA_HOME-"/usr/lib/jvm/default-java"}

# JVM Options
CATALINA_OPTS="-server
-showversion
-XX:+PrintCommandLineFlags
-XX:+UseCodeCacheFlushing
-Xms512m
-Xmx1024m
-XX:+CMSClassUnloadingEnabled
-XX:-OmitStackTraceInFastThrow
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:+CMSConcurrentMTEnabled
-XX:+ScavengeBeforeFullGC
-XX:+CMSScavengeBeforeRemark
-XX:+CMSParallelRemarkEnabled
-XX:+UseCMSInitiatingOccupancyOnly
-XX:CMSInitiatingOccupancyFraction=50
-XX:NewSize=100m
-XX:MaxNewSize=256m
-XX:SurvivorRatio=10
-XX:+DisableExplicitGC"

# Java Properties
export CATALINA_OPTS="$CATALINA_OPTS
-Dlogback.configurationFile=/var/lib/killbill/logback.xml
-Dorg.killbill.server.properties=file:///var/lib/killbill/killbill.properties
-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true
-Djava.rmi.server.hostname=$ENV_HOST_IP
-Djava.security.egd=file:/dev/./urandom
-Djruby.compile.invokedynamic=false
-Dlog4jdbc.sqltiming.error.threshold=1000"
5 changes: 5 additions & 0 deletions docker/templates/killbill/light/webapp-context.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Context>
<JarScanner>
<JarScanFilter pluggabilitySkip="*" tldSkip="*" defaultTldScan="false" />
</JarScanner>
</Context>

0 comments on commit 7e9de44

Please sign in to comment.