Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic deployment of the docker image #24

Open
1 of 2 tasks
certik opened this issue Apr 23, 2016 · 1 comment
Open
1 of 2 tasks

Automatic deployment of the docker image #24

certik opened this issue Apr 23, 2016 · 1 comment

Comments

@certik
Copy link
Member

certik commented Apr 23, 2016

First some prerequisites must be fixed:

After these are fixed, what remains is to pull the built image into docker and run it on the production server instead of the old container (the old master), which can be done with two simple commands, e.g.:

docker kill OLD_CONTAINER_ID
docker run -d -e DEPLOY_TOKEN=XXX sympy/planet-sympy:v15

The OLD_CONTAINER_ID is the ID of the currently running container, XXX is specified on the server, and sympy/planet-sympy:v15 is the docker image tag, that changes with every deployment (typically the v15 increments to v16 for the next commit to master, but this can be changed). The first command kills the old container, and the second command will download the image from docker hub automatically, if it is not already cached locally, and run it.

So this is already extremely simple, compared to what maintenance nightmare the old planet sympy setup was. I am doing this manually for now. Until #23 is fixed, I am actually also doing this manually before the above two commands:

docker build -t sympy/planet-sympy:v15 .

Again, very simple, but it'd be nice not to have to do that either. For the docker build command, I actually have to have the latest planet-sympy repo checked out and be in the repository. For the docker kill and docker run commands, I don't even have to have the planet-sympy repository checked out, so things become even simpler.

So some tooling needs to be built around this to automate this last part (docker kill and docker run). I am sure we are not the only ones facing this issue, so let's see how other people are automating this.

@certik
Copy link
Member Author

certik commented Apr 23, 2016

Looks like the deployment is very simple, according to this, it's just:

#!/bin/bash
docker pull docker.example.com/my-application:latest  
docker stop my-application  
docker rm my-application  
docker rmi docker.example.com/my-application:current  
docker tag docker.example.com/my-application:latest docker.example.com/my-application:current  
docker run -d --name my-application docker.example.com/my-application:latest  

I adapted it for our case:

#!/bin/bash
docker pull certik/planet-sympy:latest
docker stop planet
docker rm planet
docker rmi certik/planet-sympy:current  
docker tag certik/planet-sympy:latest certik/planet-sympy:current
docker run -d --name planet -e DEPLOY_TOKEN=XXX certik/planet-sympy:latest

I tested it, it seems to be working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant