Skip to content

Instantly share code, notes, and snippets.

@nnarhinen
Last active December 31, 2015 12:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nnarhinen/7986124 to your computer and use it in GitHub Desktop.
Save nnarhinen/7986124 to your computer and use it in GitHub Desktop.
My deployment script to pull and run a docker-contained clojure web application
id=$(docker ps | grep myimage:latest | awk '{ print $1 }')
docker pull quay.io/nnarhinen/myimage
new_id=$(docker run -d -p 3000 \
-e ENVIRONMENT=PRODUCTION quay.io/nnarhinen/myimage)
id=$new_id ./update-nginx-port.bash
docker stop $id
server {
listen 443;
server_name myapplication.conf;
location / {
proxy_pass http://localhost:${container_port};
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
ssl on;
ssl_certificate /etc/nginx/ssl/myapplication.com/server.crt;
ssl_certificate_key /etc/nginx/ssl/myapplication.com/server.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
ssl_prefer_server_ciphers on;
}
#!/bin/bash
if [ -z "$id" ]
then
id=$(docker ps | grep myimage:latest | awk '{ print $1 }')
fi
port=$(docker port $id 3000 | awk -F':' '{ print $2 }')
echo "Waiting for http://localhost:$port"
until curl -s "http://localhost:$port" > /dev/null
do
echo "Waiting for service to wake up"
sleep 5
done
cat myapplication.com.confg | sed -e "s/\${container_port}/$port/" > /etc/nginx/sites-available/myapplication.com
/etc/init.d/nginx reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment