Last active
December 31, 2015 12:28
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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