From ec2b6cf22eaa5e30a53c3cfe7be82fb624dcb0a8 Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Sat, 21 Jul 2018 10:18:31 -0500 Subject: [PATCH 1/3] Publish ports based on environment variable Allows two things: 1. Access a running server from outside the docker container 2. Run both a console and a server at the same time, for debugging or whatever else. --- script/docker-environment | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/docker-environment b/script/docker-environment index a1ee4736..423122d6 100755 --- a/script/docker-environment +++ b/script/docker-environment @@ -13,4 +13,5 @@ cmd="$@"; [ "$#" -eq 0 ] && cmd=bash export VOLUME="$appdir:/app" image=${DOCKER_IMAGE:=web} -exec docker-compose run --rm $image $cmd +port_publish=""; [ "${BIND_DOCKER_SERVICE_PORTS:-}" = 1 ] && port_publish="--service-ports" +exec docker-compose run $port_publish --rm $image $cmd From 36e29b82c8f1364a09128c771211a8daf9557a35 Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Sat, 21 Jul 2018 10:20:28 -0500 Subject: [PATCH 2/3] Add a script to bring up a console In addition to following the 'scripts to rule them all' pattern, this makes it easier to pull up a console by abstracting all the docker things away and will prevent a change to the binstubs from being able to run a rails console. --- script/console | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 script/console diff --git a/script/console b/script/console new file mode 100755 index 00000000..ff671891 --- /dev/null +++ b/script/console @@ -0,0 +1,7 @@ +#!/bin/sh + +appdir=$(cd $(dirname "$0")/.. && pwd) +[ -f /etc/app-env ] || exec "$appdir/script/docker-environment" $0 $@ + +export RAILS_ENV='development' +bin/rails console From e4e6b78f91cd0d210949747078b2fda63248405a Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Sat, 21 Jul 2018 10:21:54 -0500 Subject: [PATCH 3/3] Add a script for running a server In addition to following the 'script to rule them all' pattern, this makes it easier to bring up a rails server by abstracting all the docker things away (of which there are quite a few) and will prevent changes to the binstubs from being able to run a server for development purposes. --- script/server | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 script/server diff --git a/script/server b/script/server new file mode 100755 index 00000000..59d2d32b --- /dev/null +++ b/script/server @@ -0,0 +1,7 @@ +#!/bin/sh + +export BIND_DOCKER_SERVICE_PORTS=1 +appdir=$(cd $(dirname "$0")/.. && pwd) +[ -f /etc/app-env ] || exec "$appdir/script/docker-environment" $0 $@ + +bin/rails server -b 0.0.0.0