From 8d5fcbee7fbe2e671d3d2790da6776008f002d97 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 15 Apr 2015 14:55:20 +1000 Subject: [PATCH] wrapper scripts for launching --- docker/Dockerfile | 3 ++- docker/build.rb | 7 ++++--- docker/start.sh | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100755 docker/start.sh diff --git a/docker/Dockerfile b/docker/Dockerfile index 68a36f0..cfb753a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,6 @@ FROM gliderlabs/alpine ADD build_image/discourse-auth-proxy /bin/discourse-auth-proxy +ADD start.sh /bin/start.sh -CMD ["/bin/discourse-auth-proxy"] +CMD ["/bin/start.sh"] diff --git a/docker/build.rb b/docker/build.rb index 1a87958..067085c 100644 --- a/docker/build.rb +++ b/docker/build.rb @@ -1,6 +1,7 @@ require 'pty' version = "1.0.0" +$nocache = false def run(command) lines = [] @@ -20,7 +21,7 @@ end def build(path) - lines = run("cd #{path} && docker build --no-cache .") + lines = run("cd #{path} && docker build #{$nocache ? "--no-cache" : ""} .") lines[-1]["successfully built ".length..-1].strip end @@ -33,7 +34,7 @@ tag = "#{repo}:#{version}" latest = "#{repo}:#{latest}" img = build(".") -run "docker tag #{img} #{tag}" -run "docker tag #{img} #{latest}" +run "docker tag -f #{img} #{tag}" +run "docker tag -f #{img} #{latest}" diff --git a/docker/start.sh b/docker/start.sh new file mode 100755 index 0000000..197826a --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +GOOD=true + +if [ -z "$ORIGIN_URL" ]; then + unset GOOD +fi + +if [ -z "$PROXY_URL" ]; then + unset GOOD +fi + +if [ -z "$SSO_SECRET" ]; then + unset GOOD +fi + +if [ -z "$SSO_URL" ]; then + unset GOOD +fi + +if [ -z "$GOOD" ]; then + echo "#!/bin/sh" + echo + echo "# you are going to need to set the following env vars and run" + echo "# the image like this" + echo + echo "ORIGIN_URL=http://somesite.com" + echo "SSO_SECRET=somesecret" + echo "SSO_URL=http://someurl" + echo "HOST_PORT=3001" + echo + echo "docker run -d --restart:always -e ORIGIN_URL=\$ORIGIN_URL -e PROXY_URL=http://0.0.0.0:80 -e SSO_SECRET=\$SSO_SECRET -e SSO_URL=\$SSO_URL -p \$HOST_PORT:80 samsaffron/discourse-auth-proxy" +else + exec /bin/discourse-auth-proxy +fi