Skip to content

Commit

Permalink
improved container setup cli
Browse files Browse the repository at this point in the history
  • Loading branch information
pushrbx committed Oct 25, 2023
1 parent 89ff3b2 commit eecbb06
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion container-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
_JIKAN_API_VERSION=v4.0.0
SUBSTITUTE_VERSION=$_JIKAN_API_VERSION
if [ -x "$(command -v git)" ]; then
# check if we have checked out a tag or not
git symbolic-ref HEAD &> /dev/null
if [ $? -ne 0 ]; then
# if a tag is checked out then use the tag name as the version
SUBSTITUTE_VERSION=$(git describe --tags)
else
# this is used when building locally
SUBSTITUTE_VERSION=$(git describe --tags | sed -e "s/-[a-z0-9]\{8\}/-$(git rev-parse --short HEAD)/g")
fi
fi
# set JIKAN_API_VERSION env var to "latest" or a tag which exists in the container registry to use the remote image
# otherwise docker-compose will look for a locally builded image
export _JIKAN_API_VERSION=${JIKAN_API_VERSION:-$SUBSTITUTE_VERSION}

DOCKER_COMPOSE_PROJECT_NAME=jikan-api-$_JIKAN_API_VERSION
DOCKER_COMPOSE_PROJECT_NAME=jikan-api
DOCKER_CMD="docker"
DOCKER_COMPOSE_CMD="docker-compose"

Expand Down Expand Up @@ -127,6 +132,7 @@ ensure_secrets() {
}

start() {
# todo: create a marker file for initial startup, and on initial startup ask the user whether they want a local image or the remote one
validate_prereqs
ensure_secrets
exec $DOCKER_COMPOSE_CMD -p "$DOCKER_COMPOSE_PROJECT_NAME" up -d
Expand Down

0 comments on commit eecbb06

Please sign in to comment.