#!/bin/bash set -e if [ -f .env ]; then export `grep -v '^#' .env | xargs` else export DEV_UID=$(id -u) DEV_GID=$(id -g) LOCAL_DEV_CHECK=1 fi COMPOSE_FILE=docker-compose.yml if [ $# -eq 0 ]; then echo "Usage: bin/compose [args*]" echo echo "Commands:" echo " setup - Has to be run once intially. Installs backend and frontend dependencies. " echo " start - Starts both backend and frontend in the background. Acccess via http://localhost:3000/ by default." echo " run - Starts the frontend in the backround and backend in the foreground. Useful for debugging using pry." echo " * - Everything else will be passed straight to \`docker-compose\`." echo exit 1 elif [[ "$@" = "start" ]]; then # backend will be started automatically as a dependency of the frontend docker-compose -f $COMPOSE_FILE up -d frontend elif [[ "$@" = "run" ]]; then docker-compose -f $COMPOSE_FILE up -d frontend docker-compose -f $COMPOSE_FILE stop backend docker-compose -f $COMPOSE_FILE run --rm backend rm -f tmp/pids/server.pid # delete if necessary so new server can come up docker-compose -f $COMPOSE_FILE run --rm -p ${PORT:-3000}:3000 --name rails backend # run backend in TTY so you can debug using pry for instance elif [[ "$1" = "setup" ]]; then docker-compose -f $COMPOSE_FILE run backend setup yes no | docker-compose -f $COMPOSE_FILE run frontend npm install else docker-compose -f $COMPOSE_FILE $* fi