DEV: improve docker dev environment

- pass USER=discourse which is not passed in from docker exec (improves backup restore)

- add unicorn script and unicorn support (expose port 9292)
This commit is contained in:
Sam 2018-12-31 10:45:08 +11:00
parent 021f11b68e
commit fef45789c4
9 changed files with 24 additions and 9 deletions

View File

@ -59,7 +59,12 @@ echo "Using data in: ${DATA_DIR}"
mkdir -p "${DATA_DIR}"
docker run -d -p 1080:1080 -p 3000:3000 -v "$DATA_DIR:/shared/postgres_data:delegated" -v "$SOURCE_DIR:/src:delegated" $ENV_ARGS --hostname=discourse --name=discourse_dev --restart=always discourse/discourse_dev:release /sbin/boot
# 1080 mailcatcher
# 3000 puma... if you must (but unicorn is preferred)
# 9292 unicorn
# 9405 prometheus exporter
docker run -d -p 9405:9405 -p 1080:1080 -p 3000:3000 -p 9292:9292 -v "$DATA_DIR:/shared/postgres_data:delegated" -v "$SOURCE_DIR:/src:delegated" $ENV_ARGS --hostname=discourse --name=discourse_dev --restart=always discourse/discourse_dev:release /sbin/boot
if [ "${initialize}" = "initialize" ]; then
echo "Installing gems..."

View File

@ -1,5 +1,5 @@
#!/bin/bash
PARAMS="$@"
CMD="cd /src && RAILS_ENV=${RAILS_ENV:=development} bundle $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"

View File

@ -1,4 +1,4 @@
#!/bin/bash
CMD="mailcatcher --http-ip 0.0.0.0 -f"
CMD="USER=discourse mailcatcher --http-ip 0.0.0.0 -f"
docker exec -it discourse_dev /bin/bash -c "$CMD"

View File

@ -1,6 +1,6 @@
#!/bin/bash
CMD="cd /src && RAILS_ENV=development rake db:migrate"
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 && RAILS_ENV=test rake db:migrate"
CMD="cd /src && USER=discourse RAILS_ENV=test rake db:migrate"
docker exec -it -u discourse:discourse discourse_dev /bin/bash -c "$CMD"

View File

@ -1,5 +1,5 @@
#!/bin/bash
PARAMS="$@"
CMD="psql $PARAMS"
CMD="USER=discourse psql $PARAMS"
docker exec -it -u postgres discourse_dev /bin/bash -c "$CMD"

View File

@ -6,5 +6,5 @@ then
PARAMS="$PARAMS -b 0.0.0.0"
fi
CMD="cd /src && RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 LD_PRELOAD=/usr/lib/libjemalloc.so RACK_HANDLER=puma RAILS_ENV=${RAILS_ENV:=development} rails $PARAMS"
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"

View File

@ -1,5 +1,5 @@
#!/bin/bash
PARAMS="$@"
CMD="cd /src && RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 LD_PRELOAD=/usr/lib/libjemalloc.so RAILS_ENV=${RAILS_ENV:=development} bundle exec rake $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"

View File

@ -1,5 +1,5 @@
#!/bin/bash
PARAMS="$@"
CMD="cd /src && RAILS_ENV=${RAILS_ENV:=development} bundle exec sidekiq -q critical -q low -q default"
CMD="cd /src && USER=discourse RAILS_ENV=${RAILS_ENV:=development} bundle exec sidekiq -q critical -q low -q default"
docker exec -it -u discourse:discourse discourse_dev /bin/bash -c "$CMD"

10
bin/docker/unicorn Executable file
View File

@ -0,0 +1,10 @@
#!/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"