#
#   Licensed to the Apache Software Foundation (ASF) under one 
#   or more contributor license agreements.  See the NOTICE file
#   distributed with this work for additional information
#   regarding copyright ownership.  The ASF licenses this file
#   to you under the Apache License, Version 2.0 (the
#   "License"); you may not use this file except in compliance
#   with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing,
#   software distributed under the License is distributed on an
#   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
#   KIND, either express or implied.  See the License for the 
#   specific language governing permissions and limitations
#   under the License.
#

ARG JDK_VERSION=8
FROM maven:3-jdk-${JDK_VERSION}
#FROM maven:3.6.3-openjdk-${JDK_VERSION}-slim

# Base images maven:3-jdk-8 and maven:3-jdk-11 are based on Debian
# Base image maven:3-jdk-14 is based on Oracle Linux
#RUN \
#if [ -e /etc/debian_version ]; then \
#    apt-get update && \
#    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libgtk-3-0 libxtst6  && \
#    rm -rf /var/lib/apt/lists/* ; \
#elif [ -e /etc/oracle-release ]; then \
#    yum-config-manager --enable ol7_optional_latest && \
#    yum -y install xorg-x11-server-Xvfb xorg-x11-utils xorg-x11-server-utils gtk3 && \
#    yum -y clean all ; \
#fi

# Create the temp dir for Xvfb
#RUN chmod 666 /etc/passwd ; \
#	chmod 666 /etc/group

# Make /etc/passwd writeable to be able to inject username with dynamic uid/gid
#RUN chmod 666 /etc/passwd
#RUN chmod 666 /etc/group

# Create home directory
RUN mkdir -p /home/hnelson/project && chmod 777 /home/hnelson && chmod 777 /home/hnelson/project
WORKDIR /home/hnelson/project

# Add and configure entrypoint script
ADD files/entrypoint.sh /usr/local/bin
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

# Add build script and make it the default command
ADD files/build.sh /usr/local/bin
CMD "/usr/local/bin/build.sh"
