You Can Automate DevOps Yourself Using GitLab CI And Docker-Compose
You are here because you want to set up an auto deployment pipeline for your amazing full stack project.
In this article I will show you how to do this yourself.
The project I will use is a prebuilt NodeJS API, which when run, is exposed behind a Nginx proxy, and containerised using docker-compose. The project exists in GitHub under several branches Dev, UAT, Staging and Production. You can create and manage your branches any way you wish.
The code is hosted at https://github.com/Sean-Bradley/Seans-TypeScript-NodeJS-CRUD-REST-API-Boilerplate
The finished process will be,
- You commit and push your changes to a GitHub branch
- GitLab CI will detect the latest changes on GitHub and mirror the changes to your GitLab repository.
- GitLab CI will then trigger the GitLab Runner to start the pipeline for the particular branch, which will pull the latest code, build and run the docker-compose process.
- If no errors occurred during build and deployment, your latest commit will now be live.
/api/ calls to the NodeJS API, and everything else to the static folder. So you can choose the front end framework of your choice.
Docker-compose is a great tool in this setup since the internal application, your chosen components and internal architecture are treated agnostically by GitLab runner. You internal application does not have to be NodeJS and Nginx in order for docker-compose and GitLab CI to work together to create a CI/CD workflow for your application. This method works equally well for Python, Java, C#, Angular, React, MongoDB, MySQL, Redis or whatever…