On a new Ubuntu 16.04 server to be used as a runner
-
install gitlab-runner ( with docker executor ) [https://docs.gitlab.com/runner/install/linux-repository.html]
-
add additional shell executor runner [https://docs.gitlab.com/ce/ci/docker/using_docker_build.html]
-
tag each runner accordingly ( shell runner for deployment & docker runner for testing )
-
docker login with user gitlab-runner on the private container registry for building purposes
-
configure the server to be able to deploy to the server you want ( ssh in my case, so i setup a ssh key )
-
sample config, test will run on master branch, when merged to dev branch CI will be deployed to the dev server
stages:
- test
- build
- deploy
test:
stage: test
image: node:7-alpine
tags:
- test
- node:7-alpine
- flourite
services:
- mongo:latest
script:
- apk add --no-cache make gcc g++ python
- npm install
- NODE_ENV=testing ./node_modules/mocha/bin/mocha test/
build_dev:
stage: build
tags:
- build
- shell
- flourite
script:
- docker build -t $CONTAINER_REGISTRY_URL/manager-api:latest .
- docker push $CONTAINER_REGISTRY_URL/manager-api:latest
only:
- dev
deploy_dev:
stage: deploy
tags:
- build
- shell
- flourite
script:
- ssh flourite-apps-dev "cd /home/ubuntu/apps/manager-api/; ./rebuild.sh"
only:
- dev