#!/bin/bash

set -e

RESET="\e[0m"
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
BLUE="\e[94m"

GENERATED_DOCKERFILE=$(dirname     "$0")/Dockerfile

[[ -e "$CONFIG" ]] && source $CONFIG || echo -e $RED "generate_dockerfile: No such config $CONFIG" $RESET
[[ -e "$USER_CONFIG" ]] && source $USER_CONFIG || echo -e $RED "generate_dockerfile: No such user config $USER_CONFIG" $RESET
echo -e $YELLOW "\tgenerate_dockerfile: BASE_TYPE=${BASE_TYPE}" $RESET

cat <<-EOF > ${GENERATED_DOCKERFILE}
	# Automatically generated by generate_dockerfile.sh
	FROM ${PLATFORM}:${DIST_VERSION}
	LABEL maintainer="Modelon AB"

	COPY build_environment/platforms/${PLATFORM}/*.sh build_scripts/

	RUN build_scripts/install_dependencies.sh
	RUN build_scripts/install_python${PYTHON_VERSION}.sh
	RUN build_scripts/install_test_dependencies.sh
	RUN rm -rf build_scripts
EOF

# 
#    Copyright (C) 2018 Modelon AB
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the Common Public License as published by
#    IBM, version 1.0 of the License.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY. See the Common Public License for more details.
#
#    You should have received a copy of the Common Public License
#    along with this program.  If not, see
#     <http://www.ibm.com/developerworks/library/os-cpl.html/>.
