#!/bin/bash

# Copy everything over to the build/ directory so it can be bundled up.

if [ -e build ] ; then
    rm -rf build/
fi
mkdir -p build

cp -r src/* build/

# Not required that we copy this over,
# but if you have to later debug it from the source bundle,
# this makes it easier.
cp SamTemplate.json build/

if [ ! -z "$BUILD_PARAMS" ] ; then
    echo "$BUILD_PARAMS" > build/extra_params.json
fi

if [ -e static ] ; then
    sneks upload-static-assets build/static_config.json
    cp -r static build/
fi

if [ -e jinja_templates ] ; then
    cp -r jinja_templates build/
fi

if [ -e requirements.txt ] ; then
    pip3 install --no-cache-dir -t build/ -r requirements.txt
fi
