############################################################
# Dockerfile to build wildfly Hartmann Foto Documentation docker image
# Based on jboss/wildfly
############################################################

# Pull base image.
FROM hub.heyday.marketing/verboomp/wildfly:33.0.2-Final

# File Author / Maintainer
LABEL org.opencontainers.image.authors="Patrick Verboom <p.verboom@heyday.marketing>"

USER root

RUN apt-get update && apt-get install -y unzip

# install the postgres driver
RUN wget 'https://nexus.heyday.marketing/repository/maven-releases/com/ayeqbenu/wildfly/database/modules/postgres-jdbc/1.1.0/postgres-jdbc-1.1.0.zip' -O /srv/postgres-jdbc.zip \
    && unzip /srv/postgres-jdbc.zip -d ${JBOSS_HOME}/modules \
    && rm -rf /srv/postgres-jdbc.zip


# install the startup wait script to make sure postgres is booted before wildfly 
COPY wait-for-it.sh /srv/wait-for-it.sh 

RUN chmod 777 /srv/wait-for-it.sh

# copy the jacoco agent for code coverage
COPY jacoco/jacocoagent.jar /srv/jacocoagent.jar

run chmod 777 /srv/jacocoagent.jar

COPY standalone-jacoco.sh ${JBOSS_HOME}/bin/standalone-jacoco.sh

RUN chmod 777 ${JBOSS_HOME}/bin/standalone-jacoco.sh


# install the wildfly config xml file
# COPY test-standalone.xml ${JBOSS_HOME}/standalone/configuration/test-standalone.xml
COPY standalone-fotodocumentation.xml ${JBOSS_HOME}/standalone/configuration/test-standalone.xml


# install the web war file 
COPY hartmann-foto-documentation-web-*.war ${JBOSS_HOME}/standalone/deployments

# Expose the ports we're interested in
EXPOSE 8080

EXPOSE 9990

# Set the default command to run on boot
# This will boot WildFly in the standalone mode and bind to all interface
CMD ["/srv/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-c", "test-standalone.xml"]
