wrapper scripts for launching

This commit is contained in:
Sam 2015-04-15 14:55:20 +10:00
parent 6171da53db
commit 8d5fcbee7f
3 changed files with 41 additions and 4 deletions

View File

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

View File

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

35
docker/start.sh Executable file
View File

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