Skip to content

Instantly share code, notes, and snippets.

@ivan-loh
Created February 20, 2017 19:59
Show Gist options
  • Save ivan-loh/c311411eeda6ad1c31c5d76b74b3c2d5 to your computer and use it in GitHub Desktop.
Save ivan-loh/c311411eeda6ad1c31c5d76b74b3c2d5 to your computer and use it in GitHub Desktop.
Basic continuous deployment flow with GitLab Community Edition 8.16.6

On a new Ubuntu 16.04 server to be used as a runner

  1. install gitlab-runner ( with docker executor ) [https://docs.gitlab.com/runner/install/linux-repository.html]

  2. add additional shell executor runner [https://docs.gitlab.com/ce/ci/docker/using_docker_build.html]

  3. tag each runner accordingly ( shell runner for deployment & docker runner for testing )

  4. docker login with user gitlab-runner on the private container registry for building purposes

  5. configure the server to be able to deploy to the server you want ( ssh in my case, so i setup a ssh key )

  6. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment