In this post, we explain how to use the CI/CD environment CircleCI with Mesosphere’s Datacenter Operating System (DCOS). We are using DCOS for our testing environment and it works seamlessly. Our aim is to deploy our containers as Marathon apps in DCOS, and we use CircleCI for continuous integration. CircleCI creates the Docker images and pushes them into a private Docker registry.
One of the manual tasks that we were doing was to update Marathon apps manually after code changes. However, it turns out that we can automate this process via CircleCI as well.
So, to start off, we assume that you are running your DCOS on Amazon Web Services, as we will use Amazon S3 to store our JSON and shell script. In turn, CircleCI will download those at runtime and execute it.
The first step is to append the following lines in the dependencies section of your
- pip install awscli
- aws s3 cp s3://aaa-tools/scripts/marathon.json /home/ubuntu/dcos/;
- aws s3 cp s3://aaa-tools/scripts/put.sh /home/ubuntu/dcos/; chmod a+x /home/ubuntu/dcos/put.sh
- mkdir -p /home/ubuntu/dcos
Make sure to replace the S3 bucket path with your own S3 bucket name and file name. We use the following conventions:
aaa-toolsis the S3 bucket
marathon.jsonis the Marathon app spec file
put.shis the shell script that updates Marathon via its HTTP API
marathon.json file looks as follows:
put.sh would contain:
for file in *.json
echo "Installing $file..."
curl -X PUT "$MARATHON/v2/apps/$MYAPP" -d @"$file" -H "Content-type: application/json"
Now, copy the above two files (
put.sh) to the S3 bucket. Then, append the below code snippet at the very end of
circle.yml file in the docker section:
- bash /home/ubuntu/dcos/post.sh
After CircleCI triggers the build, it automatically updates the Marathon app and you’re done!
We can verify by using the version number; after the build succeeds, we will get the following message in CircleCI:
Then, in the Marathon UI check for the app version:
This should correspond with what you get from CircleCI.
In this post I walked you through setting up CircleCI with the DCOS and automating the entire CI/CD process. I hope it is useful for you and if you have any suggestions or questions, please leave a comment, below.
Note:- Original Post is here. And might be too old way to do deployment.