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

set -e

# This service is DEVELOPMENT only.

if [ "$DEVELOPMENT" = 'true' ]; then
	. /usr/bin/common.sh
	cd /frontend || exit 1
	HOME=$NPMHOME
	export HOME
	mkdir -p /frontend/dist
	chown -R "$PUID:$PGID" /frontend/dist

	log_info 'Starting frontend ...'
	s6-setuidgid "$PUID:$PGID" yarn install
	exec s6-setuidgid "$PUID:$PGID" yarn dev
else
	exit 0
fi
