DEV: Update docker development binstubs

DEV: Update docker development binstubs

  • 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
diff --git a/bin/docker/boot_dev b/bin/docker/boot_dev
index 948c08a..0eccb43 100755
--- a/bin/docker/boot_dev
+++ b/bin/docker/boot_dev
@@ -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" \
diff --git a/bin/docker/bundle b/bin/docker/bundle
index 73d39ab..82b527d 100755
--- a/bin/docker/bundle
+++ b/bin/docker/bundle
@@ -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 "$@"
diff --git a/bin/docker/discourse b/bin/docker/discourse
index 3ae9852..1ccafcf 100755
--- a/bin/docker/discourse
+++ b/bin/docker/discourse
@@ -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 "$@"
diff --git a/bin/docker/ember-cli b/bin/docker/ember-cli
new file mode 100755
index 0000000..7a843ee
--- /dev/null
+++ b/bin/docker/ember-cli
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec "$(dirname "$0")/exec" bin/ember-cli "$@"
diff --git a/bin/docker/exec b/bin/docker/exec
new file mode 100755
index 0000000..cdd16a8
--- /dev/null
+++ b/bin/docker/exec
@@ -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 \
+  "$@"
diff --git a/bin/docker/mailcatcher b/bin/docker/mailcatcher
index 385dcbb..d94e537 100755
--- a/bin/docker/mailcatcher
+++ b/bin/docker/mailcatcher
@@ -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
diff --git a/bin/docker/migrate b/bin/docker/migrate
index be9e9eb..066e07f 100755
--- a/bin/docker/migrate
+++ b/bin/docker/migrate
@@ -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
diff --git a/bin/docker/psql b/bin/docker/psql
index c25c840..43194cd 100755
--- a/bin/docker/psql
+++ b/bin/docker/psql
@@ -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 "$@"
diff --git a/bin/docker/rails b/bin/docker/rails
index 4836d47..32dba7d 100755
--- a/bin/docker/rails
+++ b/bin/docker/rails
@@ -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 "$@"
diff --git a/bin/docker/rake b/bin/docker/rake
index b1b73b7..95e030b 100755
--- a/bin/docker/rake
+++ b/bin/docker/rake
@@ -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 "$@"
diff --git a/bin/docker/rspec b/bin/docker/rspec
index c1c616f..0dadb7c 100755
--- a/bin/docker/rspec
+++ b/bin/docker/rspec
@@ -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 "$@"
diff --git a/bin/docker/shell b/bin/docker/shell
index 5f3d78c..29030df 100755
--- a/bin/docker/shell
+++ b/bin/docker/shell
@@ -1,2 +1,3 @@
 #!/bin/bash
-docker exec -it -u discourse:discourse discourse_dev /bin/bash
+
+exec "$(dirname "$0")/exec" /bin/bash "$@"
diff --git a/bin/docker/shell_root b/bin/docker/shell_root
index 930cb78..a0b2648 100755
--- a/bin/docker/shell_root
+++ b/bin/docker/shell_root
@@ -1,2 +1,3 @@
 #!/bin/bash
-docker exec -it discourse_dev /bin/bash
+
+exec docker exec -it discourse_dev /bin/bash
diff --git a/bin/docker/sidekiq b/bin/docker/sidekiq
deleted file mode 100755
index 0919990..0000000
--- a/bin/docker/sidekiq
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-PARAMS="$@"
-CMD="cd /src && USER=discourse RAILS_ENV=${RAILS_ENV:=development} bundle exec sidekiq -q critical -q low -q default -q ultra_low"
-docker exec -it -u discourse:discourse discourse_dev /bin/bash -c "$CMD"
diff --git a/bin/docker/unicorn b/bin/docker/unicorn
index ba615c0..6dd548e 100755
--- a/bin/docker/unicorn
+++ b/bin/docker/unicorn
@@ -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 "$@"

GitHub sha: 73050d90

This commit appears in #13117 which was approved by CvX. It was merged by davidtaylorhq.