Skip to content

Commit

Permalink
DEV: Update docker development binstubs
Browse files Browse the repository at this point in the history
- Add `d/ember-cli`, and publish port 4200
- Remove `d/sidekiq`. Sidekiq is now started with the rails server
- Move all `docker exec` logic into a single place, so we have one place to set environment variable pass-throughs
- Use `exec` for all bash scripts, so that return statuses are passed back correctly
- Avoid using `bin/bash -c` unnecessarily, because it makes escaping arguments difficult
  • Loading branch information
davidtaylorhq committed May 21, 2021
1 parent ab23412 commit 73050d9
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 44 deletions.
1 change: 1 addition & 0 deletions bin/docker/boot_dev
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ docker pull discourse/discourse_dev:release
docker run -d \
-p $local_publish:1080:1080 \
-p $local_publish:3000:3000 \
-p $local_publish:4200:4200 \
-p $local_publish:9292:9292 \
-p $local_publish:9405:9405 \
-v "$DATA_DIR:/shared/postgres_data:delegated" \
Expand Down
4 changes: 1 addition & 3 deletions bin/docker/bundle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash

PARAMS="$@"
CMD="cd /src && USER=discourse RAILS_ENV=${RAILS_ENV:=development} bundle $PARAMS"
docker exec -it -u discourse:discourse discourse_dev /bin/bash -c "$CMD"
exec "$(dirname "$0")/exec" bundle "$@"
4 changes: 1 addition & 3 deletions bin/docker/discourse
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash

PARAMS="$@"
CMD="cd /src && USER=discourse RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 LD_PRELOAD=/usr/lib/libjemalloc.so RAILS_ENV=${RAILS_ENV:=development} script/discourse $PARAMS"
docker exec -it -u discourse:discourse discourse_dev /bin/bash -c "$CMD"
exec "$(dirname "$0")/exec" script/discourse "$@"
3 changes: 3 additions & 0 deletions bin/docker/ember-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

exec "$(dirname "$0")/exec" bin/ember-cli "$@"
13 changes: 13 additions & 0 deletions bin/docker/exec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

exec docker exec \
-it \
-u discourse:discourse \
-w '/src' \
-e RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 \
-e LD_PRELOAD=/usr/lib/libjemalloc.so \
-e RAILS_ENV \
-e NO_EMBER_CLI \
-e QUNIT_RAILS_ENV \
discourse_dev \
"$@"
3 changes: 1 addition & 2 deletions bin/docker/mailcatcher
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash

CMD="USER=discourse mailcatcher --http-ip 0.0.0.0 -f"
docker exec -it discourse_dev /bin/bash -c "$CMD"
exec "$(dirname "$0")/exec" mailcatcher --http-ip 0.0.0.0 -f
7 changes: 3 additions & 4 deletions bin/docker/migrate
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
set -e

CMD="cd /src && USER=discourse RAILS_ENV=development rake db:migrate"
docker exec -it -u discourse:discourse discourse_dev /bin/bash -c "$CMD"
CMD="cd /src && USER=discourse RAILS_ENV=test rake db:migrate"
docker exec -it -u discourse:discourse discourse_dev /bin/bash -c "$CMD"
"$(dirname "$0")/exec" bin/rake db:migrate
RAILS_ENV=test "$(dirname "$0")/exec" bin/rake db:migrate
4 changes: 1 addition & 3 deletions bin/docker/psql
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash

PARAMS="$@"
CMD="USER=discourse psql $PARAMS"
docker exec -it -u postgres discourse_dev /bin/bash -c "$CMD"
exec "$(dirname "$0")/exec" psql "$@"
9 changes: 1 addition & 8 deletions bin/docker/rails
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
#!/bin/bash

PARAMS="$@"
if [[ $# = 1 ]] && [[ "$1" =~ "s" ]];
then
PARAMS="$PARAMS -b 0.0.0.0"
fi

CMD="cd /src && USER=discourse RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 LD_PRELOAD=/usr/lib/libjemalloc.so RACK_HANDLER=puma RAILS_ENV=${RAILS_ENV:=development} rails $PARAMS"
docker exec -it -u discourse:discourse discourse_dev /bin/bash -c "$CMD"
exec "$(dirname "$0")/exec" bin/rails "$@"
4 changes: 1 addition & 3 deletions bin/docker/rake
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash

PARAMS="$@"
CMD="cd /src && USER=discourse RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 LD_PRELOAD=/usr/lib/libjemalloc.so RAILS_ENV=${RAILS_ENV:=development} bundle exec rake $PARAMS"
docker exec -it -u discourse:discourse discourse_dev /bin/bash -c "$CMD"
exec "$(dirname "$0")/exec" bin/rake "$@"
4 changes: 1 addition & 3 deletions bin/docker/rspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash

PARAMS="$@"
CMD="cd /src && USER=discourse RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 LD_PRELOAD=/usr/lib/libjemalloc.so RAILS_ENV=${RAILS_ENV:=test} bin/rspec $PARAMS"
docker exec -it -u discourse:discourse discourse_dev /bin/bash -c "$CMD"
exec "$(dirname "$0")/exec" bin/rspec "$@"
3 changes: 2 additions & 1 deletion bin/docker/shell
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
docker exec -it -u discourse:discourse discourse_dev /bin/bash

exec "$(dirname "$0")/exec" /bin/bash "$@"
3 changes: 2 additions & 1 deletion bin/docker/shell_root
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
docker exec -it discourse_dev /bin/bash

exec docker exec -it discourse_dev /bin/bash
5 changes: 0 additions & 5 deletions bin/docker/sidekiq

This file was deleted.

9 changes: 1 addition & 8 deletions bin/docker/unicorn
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
#!/bin/bash

PARAMS="$@"
if [[ $# = 1 ]] && [[ "$1" =~ "s" ]];
then
PARAMS="$PARAMS -b 0.0.0.0"
fi

CMD="cd /src && USER=discourse RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 LD_PRELOAD=/usr/lib/libjemalloc.so RAILS_ENV=${RAILS_ENV:=development} bin/unicorn $PARAMS"
docker exec -it -u discourse:discourse discourse_dev /bin/bash -c "$CMD"
exec "$(dirname "$0")/exec" bin/unicorn "$@"

0 comments on commit 73050d9

Please sign in to comment.