#!/command/with-contenv bash
# shellcheck shell=bash

set -e

# This service is DEVELOPMENT only.

if [ "$DEVELOPMENT" == "true" ]; then
	. /bin/common.sh
	cd /app/frontend || exit 1
	log_info 'Starting frontend ...'
	HOME=/tmp/npmuserhome
	export HOME
	mkdir -p /app/frontend/dist
	chown -R npmuser:npmuser /app/frontend/dist
	# If yarn install fails: add --verbose --network-concurrency 1
	s6-setuidgid npmuser yarn install
	exec s6-setuidgid npmuser yarn watch
else
	exit 0
fi
