Wednesday 21 March 2018

I need some help getting CI/CD working with my new todomvc example app, how can I automate my deployment processes using gitlab ci/cd?

Alright so I have a SailsJs 0.12 app that I am writing right now which will be containerized to help me learn about dockerized nodejs apps and a more automated workflow for CI/CD.Traditionally, i was using codeship that had ssh keys stored, and given a successful test, it would ssh into the production server, cd to the apps directory, git pull, then restart the nodejs app via pm2.Now that I am going to dockerized setup with this new example app, I am not sure how to go about automating the workflow.I am using gitlab-ee with gitlab-runners running so it spins up a docker container for each trigger.Right now I have the following separate containers in a docker-compose.yml:MySQLRedisSailsJs 0.12 running on node 9.5.0nginx - handles reverse proxy of the sails app, and eventual host for the React SPA codeMy gitlab-ci.yml right now is setup for the sails app to simply run yarn install && yarn run test off of the sails app's latest code.I imagine the workflow would be something like this...hack away, boom! code is now ready for 1.0push code to masterpipeline gets triggered in gitlab to test, build, then deployI got the testing part working, its pretty simple gitlab just runs yarn run test off the last commitafter all the tests pass, is where I start to get lost. I imagine with docker containers you just need to build a new image with a new tag (tag latest, or tag v1.0?)git clone the repo (is this even needed?) or can i just skip to docker buildrun docker build . -t todomvc-api:latestrun docker push registry.example.com/ndboost/todomvc-api:latestThe other part I am also confused about is the deploy part, how do i get my production server to pull the new image once its built? Do i need to ssh into the host to trigger the docker commands and restart the container with the new image? Or will something like v2tec/watchtower that would detect the push to registry.example.com for my todomvc-api image and then pull it and restart the container automatically?

Submitted March 21, 2018 at 06:03PM by ndboost

No comments:

Post a Comment