#!/usr/bin/env bash
set -e

if [[ "$1" == "api" ]]; then
	echo "docker-entrypoint: starting api server"
	./cli db -- migrate
	exec dumb-init ./cli api
elif [[ "$1" == "worker" ]]; then
	echo "docker-entrypoint: starting worker"
	exec dumb-init ./cli worker
elif [[ "$1" == "cli" ]]; then
	echo "docker-entrypoint: starting cli"
	shift 1
	exec ./cli "$@"
else
	echo "docker-entrypoint: missing argument, one of: api, worker, cli"
	exit 1
fi
