mvn -f iterative-dev/pom.xml clean package -DskipTests | fgrep -v 'Downloaded' | fgrep -v 'Downloading';
if [ $? -ne 0 ]; then
    echo "iterative-dev build failed"
    exit 1;
fi

# We need to copy the initialize npm in to use locally in che.
rm -rf initialize
mkdir -p initialize
cp -r ../initialize/*.json ../initialize/src ./initialize

# read and source the .env file
env_file=./devbuild.env
if [ -f $env_file ]; then
    set -o allexport
    source $env_file
    set +o allexport
else
    # by default fallback to production mode
    NODE_ENV=production
fi

docker build -t codewind-pfe-$(../../script/platform.sh) \
--file $1 \
--label "org.label-schema.build-date=$(date '+%Y-%m-%dT%k:%M:%S%z')" \
--label "org.label-schema.vcs-ref=$(git rev-parse HEAD)" \
--label "org.label-schema.version=" \
--build-arg NODE_ENV=$NODE_ENV \
.
