Skip to content

Commit

Permalink
docs and more
Browse files Browse the repository at this point in the history
  • Loading branch information
kael-shipman committed Jan 11, 2024
1 parent 57295d7 commit 7ad839c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.git*
node_modules
dist
dist
.docker-compose-env
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
**/*.local.yml
**/.env/local
node_modules
dist
dist
.docker-compose-env
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ Some key points:
local monorepo linked in. If you want to run the actual built containers statically, try `pnpm docker:compose prod up -d`.
You can bring the system back down by running `pnpm docker:compose [ENV] down`, and you can additionally pass any
arguments you'd like to docker compose, e.g., `pnpm docker:compose [ENV] logs -f`.
* Note that I've implemented a small environment caching mechanism so you don't always have to pass the environment
along with `pnpm docker:compose`. This is just to avoid situations where you brought up the prod stack and then
accidentally ran a command against the (non-existent) dev stack or something because you forgot to include `prod`
again.


### ESLint
Expand Down
13 changes: 12 additions & 1 deletion scripts/docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ function echo_help() {
}

ENV=
SAVED_ENV="$([ -f "$ROOT/.docker-compose-env" ] && cat "$ROOT/.docker-compose-env" || true)"

while [ $# -gt 0 ]; do
case "$1" in
-h|--help)
echo_help
exit 0
;;
-f|--force)
FORCE=1
shift
;;
-*|build|config|cp|create|down|events|exec|images|kill|logs|ls|pause|port|ps|pull|push|restart|rm|run|start|stop|top|unpause|up|version|wait)
break
;;
Expand All @@ -46,14 +51,20 @@ while [ $# -gt 0 ]; do
done

if [ -z "$ENV" ]; then
ENV="dev"
ENV="$([ -n "$SAVED_ENV" ] && echo "$SAVED_ENV" || echo dev)"
fi

if ! [ -f "$ROOT/deploy/compose.${ENV}.yml" ]; then
>&2 echo "E: Unknown environment: '$ENV'. Available environments: ${OPTS[*]}"
exit 1
fi

if [ -n "$SAVED_ENV" ] && [ "$ENV" != "$SAVED_ENV" ] && [ -z "$FORCE" ]; then
>&2 echo "E: Environment changed from '$SAVED_ENV' to '$ENV'. Please use the `-f\|--force` argument to confirm."
exit 1
fi
echo -n "$ENV" > "$ROOT/.docker-compose-env"

ARGS=(-f "$ROOT/deploy/compose.base.yml" -f "$ROOT/deploy/compose.${ENV}.yml")
if [ -f "$ROOT/deploy/compose.local.yml" ] && [ "$ENV" != 'local' ]; then
ARGS+=(-f "$ROOT/deploy/compose.local.yml")
Expand Down

0 comments on commit 7ad839c

Please sign in to comment.