You'll need roughly 2 minutes to read this article.
You can find a sample repository for deploying with Docker Swarm and Codeship Pro on Github here.
Deploying your application with Docker Swarm and Codeship Pro is easy. You’ll just need a few things:
A provider to host your Swarm (AWS/Google Cloud/Azure/Etc)
A Docker Compose V3 file to orchestrate your Swarm
The Docker Compose V3 file is intended to orchestrate your production container setup. Your Swarm deployment will rely on this file for knowing what to deploy and how to configure it.
The codeship-services.yml file, while very similar in syntax to a Docker Compose file, is intended to outline the containers and commands you need for your CI/CD pipeline.
To deploy, you will also need to be able to authenticate with your cloud infrastructure provider. We provide documentation for general authentication, as well as sample code and integration images, with the common cloud providers:
If you have any specific authentication questions or need help, contact our helpdesk.
To deploy with Swarm, you will want to run a
docker stack deploy command via your codeship-steps.yml file.
The specifics of this command will depend on the specifics of your application, and we recommend reading the Docker documentation to learn more.
- name: swarm-deploy service: your-app command: docker stack deploy --compose-file docker-stack.yml app
Note that this example is using a
docker command. This will only work if the container can find a Docker host. In a normal use case, this example would be assuming that your container has already authenticated with and connected to an external resource, such as AWS or Google Cloud, where the Docker host that is expected to run these commands is available.
To learn more, you can visit our sample repository to see a working example of using Compose V3 and Swarm to deploy to Google Cloud.
We also have a couple of code examples and sample projects available.