...
 
Commits (1)
......@@ -58,6 +58,16 @@ package:
script:
- mvn -B war:war
docker_image:
stage: deploy
tags:
- kaniko
dependencies:
- package
script:
- echo "$DOCKER_REGISTRY_CONFIG" > /kaniko/.docker/config.json
- /kaniko/executor --context "$CI_PROJECT_DIR" --dockerfile "$CI_PROJECT_DIR/src/main/docker/Dockerfile" --destination "$DOCKER_REGISTRY_HOST/arsnova-app/backend" --build-arg "ARSNOVA_BACKEND_ARCHIVE_PATH=`echo $WAR_FILE`"
.deploy: &deploy
stage: deploy
tags:
......
FROM openjdk:8-jre
LABEL maintainer "Daniel Gerhardt <code@dgerhardt.net>"
ARG ARSNOVA_BACKEND_ARCHIVE_PATH
ARG ARSNOVA_PROPERTIES_SRC_PATH=/src/main/resources/arsnova.properties.example
ARG ENTRYPOINT_SRC_PATH=/src/main/docker/docker-entrypoint.sh
ENV ARSNOVA_COUCHDB_HOST couchdb
ENV ARSNOVA_COUCHDB_PORT 5984
ENV ARSNOVA_COUCHDB_NAME arsnova
ENV ARSNOVA_COUCHDB_USERNAME admin
ENV ARSNOVA_COUCHDB_PASSWORD ""
ARG TOMCAT_VALVE='<Valve\
className="org.apache.catalina.valves.RemoteIpValve"\
remoteIpHeader="x-forwarded-for"\
protocolHeader="x-forwarded-proto" />'
# HTTP
EXPOSE 8080
# WebSocket
EXPOSE 8090
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gawk \
libservlet3.1-java \
libtcnative-1 \
tomcat8 \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /opt/arsnova
RUN echo "$ARSNOVA_BACKEND_ARCHIVE_PATH"
COPY "$ARSNOVA_BACKEND_ARCHIVE_PATH" arsnova-backend.war
COPY "$ARSNOVA_PROPERTIES_SRC_PATH" arsnova.properties.example
RUN \
ln -s "`pwd`/arsnova-backend.war" /var/lib/tomcat8/webapps/api.war && \
sed \
# Remove escaped line breaks
-e ':a;N;$!ba;s/\\\n *//g' \
arsnova.properties.example | \
# Adjust defaults for Docker vnet
sed \
-e 's/^\(socketio.bind-address *= *\).*/\10.0.0.0/g' \
-e '/^#socketio.proxy-path *=/s/^#//g' \
-e 's/^#\(session.guest-session.cleanup-days *= *\).*/\10/g' \
-e 's/^#\(user.cleanup-days *= *\).*/\10/g' | \
# Add environment variable support to properies file
gawk '{ \
match($0, /^(# ?)?([a-z0-9._-]+)( *= *)(.*)$/, a); \
if (RLENGTH != -1) { \
b = gensub(/[.-]/, "_", "g", a[2]); \
defaultVal = ""; \
if (!a[1]) defaultVal = a[4]; \
out = a[2] a[3] "${ARSNOVA_" toupper(b) ":" defaultVal "}"; \
} else { \
out = $0; \
} \
print out; \
}' \
> arsnova.properties && \
rm arsnova.properties.example && \
mkdir /etc/arsnova && \
ln -s "`pwd`/arsnova.properties" /etc/arsnova/ && \
sed -i "s#</Host># $TOMCAT_VALVE\n\n </Host>#g" /etc/tomcat8/server.xml
COPY "$ENTRYPOINT_SRC_PATH" /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["run"]
#!/bin/sh
if [ "$1" = run ]; then
printf "Testing database connection"
for i in `seq 1 10`; do
printf .
curl -o /dev/null -s -I -f "http://couchdb:5984/"
if [ $? -eq 0 ]; then
echo " OK."
break;
elif [ $i -ge 10 ]; then
echo " FAILED."
exit 1;
fi
sleep 10;
done
fi
export CATALINA_HOME=/usr/share/tomcat8
export CATALINA_BASE=/var/lib/tomcat8
exec $CATALINA_HOME/bin/catalina.sh "$@"