#!/bin/bash

set -eu

# cd to location of script
cd "$(dirname "$(realpath "$0")")"

# We generate first, and capture the output, to avoid overwriting the file on error.
# To avoid jsonnet needing to exist locally, we run it in a container.
output=$(docker run --rm -i sparkprime/jsonnet -V tag="$(./get-build-tag)" - < docker-compose.jsonnet)

{
	echo "# DO NOT EDIT THIS FILE!"
	echo "# This file is generated from docker-compose.jsonnet"
	echo "# It can be generated by running ./generate-docker-compose"
	echo "$output"
} > docker-compose.yml