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
This commit is contained in:
David Taylor 2021-05-21 16:24:09 +01:00
parent ab23412113
commit 73050d9049
15 changed files with 32 additions and 44 deletions

View File

@ -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" \

View File

@ -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 "$@"

View File

@ -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
bin/docker/ember-cli Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
exec "$(dirname "$0")/exec" bin/ember-cli "$@"

13
bin/docker/exec Executable file
View File

@ -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 \
"$@"

View File

@ -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

View File

@ -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

View File

@ -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 "$@"

View File

@ -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 "$@"

View File

@ -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 "$@"

View File

@ -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 "$@"

View File

@ -1,2 +1,3 @@
#!/bin/bash
docker exec -it -u discourse:discourse discourse_dev /bin/bash
exec "$(dirname "$0")/exec" /bin/bash "$@"

View File

@ -1,2 +1,3 @@
#!/bin/bash
docker exec -it discourse_dev /bin/bash
exec docker exec -it discourse_dev /bin/bash

View File

@ -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"

View File

@ -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 "$@"