IMAGE opendatakit_2.0.5-210106
FROM alpine3.12-tomcat8.5_8.5.61-210106

RUN EOF
    # Download OpenDataKit
    wget https://github.com/getodk/aggregate/releases/download/v2.0.5/ODK-Aggregate-v2.0.5.war -O /tmp/odk.war
    mkdir /srv/tomcat/webapps/ROOT
    unzip /tmp/odk.war -d /srv/tomcat/webapps/ROOT

    # Update Postgres JDBC driver
    rm /srv/tomcat/webapps/ROOT/WEB-INF/lib/postgresql-42.1.4.jre7.jar
    wget https://jdbc.postgresql.org/download/postgresql-42.2.18.jar -O /srv/tomcat/webapps/ROOT/WEB-INF/lib/postgresql-42.2.18.jar

    # Change webapps ownership
    chown -R tomcat:tomcat /srv/tomcat/webapps

    # Cleanup
    rm /tmp/odk.war
EOF

USER tomcat
WORKDIR /srv/tomcat
CMD /usr/bin/catalina.sh run
