# Copyright (c) 2018-2021 Contributors to the Eclipse Foundation
# 
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
# 
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
# 
# SPDX-License-Identifier: EPL-2.0
#

# The base image is chosen based on the build being issued
FROM quay.io/almalinux/almalinux:8

#File author / Maintainer
MAINTAINER ISM Build

WORKDIR /usr/share/amlen-proxy/bin

# Add RPM in a temporary directory inside the container
# Make sure that imaproxy.rpm is available in the directory where "docker build" command
# is being executed
ADD ./imaproxy.rpm /tmp/

# Update/install prereq packages
RUN yum -y upgrade

# For almalinux 8 and 9 libedit-devel comes from epel so we need to try to enable those
# The steps are essentially optional as not all distros will suport the commands
RUN yum -y install epel-release || true
RUN yum -y install dnf-plugins-core || true
RUN dnf config-manager --set-enabled powertools || true

# Hopefully we can now install all the required prereqs, this is not optional
RUN yum -y install gdb net-tools openssh-clients openssl tar perl zip logrotate bzip2 unzip cronie less libedit-devel curl libbson mongo-c-driver

# Install the Bridge itself
RUN yum -y install /tmp/imaproxy.rpm

# Delete imaproxy.rpm from temporary directory
RUN rm -f /tmp/imaproxy.rpm

ENV LD_LIBRARY_PATH /usr/share/amlen-proxy/lib64:${LD_LIBRARY_PATH}
ENV PATH /usr/share/amlen-proxy/bin:${PATH}

#Uncomment below USER line to run as a non-root user (but do the above steps 1-4 as well!)
#USER imaproxy:imaproxy

#ENTRYPOINT "/bin/bash"
ENTRYPOINT [ "/usr/share/amlen-proxy/bin/startProxy.sh" ]



