How to deploy/run a Docker image from a build server - docker

Having built,run and executed tests against a docker image on a CI build server(TeamCity2017), how should we deploy it to further machines?
How, for example, if we push it to a Docker registry, would our CI server instruct the target machine to pull and run the image? I.e. where it an application we would use Octopus for this deployment step, but our Octopus server doesn't support Docker deployments as yet.
Any guidance appreciated.
Michael McD.

I would use Octo to deploy your images onto target machines. You'd need to use powershell scripts to have your machines run the images. Or you can use something like Rancher, which is a docker swarm manager. There is no feasible way to have TeamCity deploy your images. The software simply isn't built to be able to do deploys.
The Rancher solution would not be automated, at least not to my knowledge. You would have to trigger upgrades when a new image is pushed to the docker registry.

Related

Jenkins CI/CD deployment to AWS EKS without Docker registry

We are trying to setup a development CI/CD pipeline with Jenkins that builds the Docker Images and deploy that Directly to AWS EKS cluster. Is this even possible??
Our Existing system
Jenkins as CI to pick the Code from GitLab and Build Docker Image
After Build, Jenkins push the Image to Jfrog Artifactory(Professional)
We use Harness for CD, that picks the Image from Artifactory and deploy that
to AWS
Here, Artifiactory and Harness Incurs cost for us and we don't want to use that for Development builds. So, we have setup a Docker Registry with Soantype Nexus3 OSS(open source version).
I would like to know two Options here:
if I can use Jenkins to Build Docker Image and Push that to Nexus Docker Registry and Use Jenkins Itself for CD to deploy that to AWS EKS?
Build Docker images with Jenkins and directly deploy that to AWS EKS without even having to store it in a docker registry?
Any suggestions and help is highly appreciated!
the first option much better.
because one day may need roll-back docker image on Kubernetes. (even development environment)
or you can use AWS ECR. it's easier to use on EKS.
and I think ECR is cheaper than Nexus operation cost.
You may be happy to know that Harness has created a free software version of it's CD service, called Harness Continuous Delivery Community Edition, which should work nicely for your development builds.

CI/CD with Docker - what is the final deployment step?

I am developing a small website (Ruby/Sinatra) to be used internally where I work. (Simply, it crunches some source data and generates reports.)
I'm want to deploy it using Docker and have a set up that works on my dev environment, but I'm trying to understand the workflow for "production" deployment (we're using Jenkins).
I've read lots of articles about deployment workflows using Docker, but they all seem to stop at "and then push your image to the Docker registry". What seems to be missing is how to then take that image and actually update the application.
I appreciate that every application is likely to be different, but what is the next step? I'm aware of lots of different frameworks like Chef, Puppet, Ansible that could be used, but my question really is - how do I integrate that into my CI/CD pipeline? E.g. does a job "push" the changes to the production server, or should a Jenkins slave be running on the production server to execute a job directly on the server?
There are several orchestration tools like docker-swarm, kubernetes and rancher. In docker swarm for example you create services and can update the versions in blue-green deployment manner also for just one instance (then there is no blue-green :) ) and if you just use docker run you should check your running container, stop and remove it if its running an start your docker container with the newer image version.
It depends on how your application is configured to run. In my case, I have a call to "docker run" in a systemd script. It's configured to just restart if it ever stops.
So, in my Jenkinsfile, after I push the image to the registry, I do a "docker pull" (my Jenkins agent is running on the same box that the application is running on), and then a "docker stop". That causes the application to exit, then restarts, which causes it to get the new version that was just pulled, and now it's running the new version.

Jenkins master + OSX slaves fleet dockerized

I see no problem with dockerizing Jenkins master (there is even an image ready to use) however I would like to dockerize also slaves. However I'd like these slaves to run iOS builds, so it neeeds slaves to run OS X. Is it doable? Maybe Vagrant, Puppet, Chef anything else could help to automate slaves provisioning?
So you can't use Docker on iOS so you'll need something else there but otherwise this kind of thing is usually handled via Jenkins plugins instead of an external configuration management tool. Jenkins likes to controls its own universe.
There is a Docker Plugin which allows you to deploy dockerized slaves. Follow the documentation, it is pretty simple (no chef/puppet needed)
The problem is that I am not sure that it is possible to have XCode inside the docker container.
Try docker search OSX and docker search Xcode for the image in the Docker Hub.

Run Jenkins master and slave with Docker

I want to setup Jenkins master on server A and slave on server B with use of Docker.
Both servers are virtual machines dedicated for Jenkins.
Currently I have started Docker container on server A for master, based on the official Jenkins docker image. But what docker image should I use for Jenkins slave?
That actually depends on the environment and tools you need in your build environment. For example, if you build a C project, you would need an image containing a C compiler and possibly make if you use Makefiles. If you build a Java project, you would need a JDK with a Java compiler and possibly Ant / Maven / Gradle if you use them as part of your build.
You can use the evarga/jenkins-slave as a good starting point for your build slave.
This image already contains JDK. If you simply need JDK and Maven on your build slave, you can build your Docker image with the following Dockerfile:
FROM evarga/jenkins-slave
run apt-get install maven
Using Docker images for build slaves is actually a good idea. Some of the reasons appear at Templating Jenkins Build Environments with Docker Containers:
Docker has established itself as a popular and convenient way to
bootstrap isolated and reproducible environments, which enables Docker
containers to be the most maintainable slave environments. Docker
containers’ tooling and other configurations can be version controlled
in an environment definition called a Dockerfile, and Dockerfiles
allows multiple identical containers can be created quickly using this
definition or for more customized off-shoots to be created by using
that Dockerfile’s image as a base.
I suggest you take trying to use dynamic|ephemeral docker nodes, instead of manually creating nodes and connecting to them via ssh. Take a look at https://engineering.riotgames.com/news/putting-jenkins-docker-container, it's very powerful and I think it's one of killer usecases for Docker.

gitlab CI build runs on my local docker container

I've been trying gitlab and its CI workflow these days, but found myself confused when I saw these messages during a build:
gitlab-ci-multi-runner 0.6.2 (3227f0a)
Using Docker executor with image mydocker:latest ...
Running on runner-5498280b-project-20053-concurrent-0 via jls-MacBook-Pro...
I register a project specified runner instead of using the shared ones.
Is gitlab actually running all the CI build process via my own machine? What if other co-workers push to this project while my computer was off? I just thought that gitlab would provide every project with a cloud CI server... So , I don't want to turn my own computer into such a server. Am I missing something on its docs?
See this Gitlab Docs
Is gitlab actually running all the CI build process via my own machine?
--Yes, Because you specified it. If you don't want to run into your machine, Then deploy the docker to other server.
What if other co-workers push to this project while my computer was off?
--Then, no build will going to happen,

Resources