Skip to content

Instantly share code, notes, and snippets.

@blakewest
Last active January 30, 2022 11:58
Show Gist options
  • Save blakewest/cd61aad245e0926b8f261b785e7fdf08 to your computer and use it in GitHub Desktop.
Save blakewest/cd61aad245e0926b8f261b785e7fdf08 to your computer and use it in GitHub Desktop.
1 */8 * * * aws s3 cp --recursive ~/looker s3://looker-config/looker --exclude="*.jar" --exclude="*.zip" --exclude="awscli-bundle/_"
FROM quay.io/aptible/java:oracle-java8
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
RUN apt-get update && apt-get -y install libc6-dev unzip curl
RUN groupadd looker && useradd -m -g looker -s /bin/bash looker
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.5/supercronic-linux-amd64 \
SUPERCRONIC=supercronic-linux-amd64 \
SUPERCRONIC_SHA1SUM=9aeb41e00cc7b71d30d33c57a2333f2c2581a201
RUN curl -fsSLO "$SUPERCRONIC_URL" \
&& echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \
&& chmod +x "$SUPERCRONIC" \
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
USER looker
RUN mkdir /home/looker/looker
WORKDIR /home/looker/looker
ADD crontab /looker/crontab
ENV S3_URL https://s3.amazonaws.com/download.looker.com/aeHee2HiNeekoh3uIu6hec3W
RUN wget $S3_URL/looker-latest.jar -O looker.jar
COPY templates/looker looker
USER root
RUN wget "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -O "awscli-bundle.zip"
RUN unzip awscli-bundle.zip
RUN sudo /usr/bin/python3 ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
RUN rm awscli-bundle.zip
RUN chmod 0777 -R /home/looker/looker
USER looker
RUN mkdir -p log && touch log/looker.log
ENV PORT 9999
EXPOSE 9999
#!/bin/sh
# Make sure we're running Java 1.8
JAVA_VER=$(java -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q')
if [ "$JAVA_VER" -le 17 ]; then
echo "The Java version installed on this host is too old. Please upgrade to the latest version of Java 8."
exit 1
fi
cd $HOME/looker
# set your java memory to 80% of container size
JM=`expr ${APTIBLE_CONTAINER_SIZE} \* 1024 \* 8 / 10`
JAVAMEM="${JM}k"
METAMEM="800m"
# Extra Java startup args and Looker startup args. These can also be set in
# a file named lookerstart.cfg
JMXARGS="-Dcom.sun.akuma.jvmarg.com.sun.management.jmxremote -Dcom.sun.akuma.jvmarg.com.sun.management.jmxremote.port=9910 -Dcom.sun.akuma.jvmarg.com.sun.management.jmxremote.ssl=false -Dcom.sun.akuma.jvmarg.com.sun.management.jmxremote.local.only=false -Dcom.sun.akuma.jvmarg.com.sun.management.jmxremote.authenticate=true -Dcom.sun.akuma.jvmarg.com.sun.management.jmxremote.access.file=${HOME}/.lookerjmx/jmxremote.access -Dcom.sun.akuma.jvmarg.com.sun.management.jmxremote.password.file=${HOME}/.lookerjmx/jmxremote.password"
# to set up JMX monitoring, add JMXARGS ot JAVAARGS
JAVAARGS=""
LOOKERARGS="--no-ssl"
# check for a lookerstart.cfg file to set JAVAARGS and LOOKERARGS
if [ -r ./lookerstart.cfg ]; then
. ./lookerstart.cfg
fi
# check if --no-ssl is specified in LOOKERARGS and set protocol accordingly
PROTOCOL=""
echo "${LOOKERARGS}" | grep -q "\-\-no\-ssl"
if [ $? -eq 0 ]
then
PROTOCOL='http'
else
PROTOCOL='https'
fi
start() {
if [ -e .deploying ]; then
echo "Startup suppressed: ${PWD}/.deploying file exists. Remove .deploying file to allow startup"
exit 1
fi
LOCKFILE=.starting
if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then
echo "Startup suppressed: ${LOCKFILE} contains running pid, startup script is already running"
exit 1
fi
# make sure the lockfile is removed when we exit and then claim it
trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT
echo $$ > ${LOCKFILE}
fixcrypt
java \
-XX:+UseG1GC -XX:MaxGCPauseMillis=2000 -XX:MaxMetaspaceSize=$METAMEM \
-Xms$JAVAMEM -Xmx$JAVAMEM \
-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps \
-Xloggc:/tmp/gc.log ${JAVAARGS} \
-jar looker.jar start ${LOOKERARGS}
if [ -x ./tunnel ]; then
./tunnel start
fi
rm -f ${LOCKFILE}
}
stop() {
pid=`cat .tmp/looker.pid`
if [ -f .status_server_token ] && [ -x /usr/bin/curl ]; then
state="running"
token=`cat .status_server_token`
request="control/stop?token=${token}"
timeout 20 curl -m 10 -ks ${PROTOCOL}://127.0.0.1:9999/${request} > /dev/null 2>&1
ECODE=$?
[ $ECODE -eq 7 ] && state="stopped"
if [ $ECODE -gt 7 ] ; then
kill $pid
fi
for i in {1..30}; do
timeout 20 curl -m 5 -ks ${PROTOCOL}://127.0.0.1:9999/alive > /dev/null 2>&1
ECODE=$?
if [ $ECODE -eq 7 ]; then
state="stopped"
break
fi
if [ $ECODE -gt 7 ] ; then
kill -9 $pid
fi
sleep 1
done
if [ "${state}" = "running" ]; then
echo "Force Stop Looker Web Application"
kill $pid
kill -0 $pid && kill -9 $pid
fi
else
timeout 20 java -jar looker.jar stop
if [ $? -ne 0 ]; then
kill -9 $pid
fi
fi
}
fixcrypt() {
CRYPTEXIST=`/sbin/ldconfig -p | grep -c '\slibcrypt.so\s'`
if [ $CRYPTEXIST -eq 0 ]; then
if [ ! -d .tmp ]; then
mkdir .tmp
fi
CRYPTLN=`/sbin/ldconfig -p | grep '\slibcrypt\.so\.[[:digit:]]' | awk '{print $(NF)}'`
ln -s -f $CRYPTLN `pwd`/.tmp/libcrypt.so
export LD_LIBRARY_PATH=`pwd`/.tmp/:$LD_LIBRARY_PATH
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
echo "Restarting Looker Web Application" "looker"
stop
sleep 3
start
;;
status)
curl -ks ${PROTOCOL}://127.0.0.1:9999/alive > /dev/null 2>&1
if [ $? -eq 7 ]; then
echo "Status:Looker Web Application stopped"
exit 7
else
echo "Status:Looker Web Application running"
exit 0
fi
;;
*)
java -jar looker.jar $*
;;
esac
exit 0
web: cd ~/ && aws s3 cp --recursive s3://looker-config/looker ./looker --exclude="*.jar" --exclude="*.zip" --exclude="awscli-bundle/_" && chmod 777 looker/looker && cd looker/ && ./looker start && tail -f log/looker.log
cron: exec supercronic /looker/crontab
@oldfaust
Copy link

Hi Blake,

S3_URL https://s3.amazonaws.com/download.looker.com/aeHee2HiNeekoh3uIu6hec3W doesn't seem to work anymore. Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment