Public | Automated Build

Last pushed: 5 months ago
Short Description
CIEnvy runtime containers
Full Description

CIEnvy

A novel CI controller that manages whole CI flows. Works well with Drone CI

Setup

  1. yarn install
  2. yarn run build
  3. Make changes accordingly in config

Start

yarn forever:start

Stop

yarn forever:stop

Restart

yarn forever:restart

Observing logs

tail -f cienvy.log

Using Docker

Assume host path is /home/core/cienvy, put git deploy private key (id_rsa) in the host path. Then:

docker run -d --restart=always --name="cienvy" \
-p 9090:9090 \
-v /home/core/cienvy:/cienvy \
-v /home/core/cienvy-client:/cienvy-client \
-v cienvy-volumes:/volumes \
southbanksoftware/cienvy

Usage

Adding/Configuring CI node

  1. enable wanted repo in Drone
  2. Add .cienvy folder in the repo, and create a config.yml
  3. Create wanted workflows in .cienvy/src
  4. Commit and push to the repo with [CI CONF] (or [CONF CI], [CI CONFIG], [CONFIG CI]) in commit message. This will instruct CIEnvy to configure the corresponding CI node only. Note: you have to do this for each node affected whenever you have changed CI network structure or added new nodes. You don't need to do this for updating volume mappings.

Performance notes

In Docker for Mac, named volume is as fast as container fs, and mounted volume is the slowest due to virtualisation bridging to host fs. Therefore, named volume is used in CI container to persist build artifact, and when host needs to access those artifacts, some ephemeral containers can be created to either symlinking or copying them.

Docker Configuration

Creating needed volumes

docker volume create cienvy-volumes
docker volume create drone-server-data

Inspecting volumes

docker run --rm -it -v cienvy-volumes:/volumes -v drone-server-data:/drone-server-data southbanksoftware/cienvy:node-nm-mongo bash
Cleanup volumes
cd /volumes/
shopt -s extglob
rm -rf !(yarn-cache)

Drone Configuration

docker-compose.yaml

version: '2'

services:
  drone-server:
    image: drone/drone:latest
    container_name: drone-server
    restart: always
    ports:
      - 8000:8000
    volumes:
      - drone-server-data:/var/lib/drone/
    environment:
      - GIN_MODE=release
      - DRONE_HOST=https://cienvy.au.ngrok.io
      - DRONE_GITHUB=true
      - DRONE_GITHUB_CLIENT=${DRONE_GITHUB_CLIENT}
      - DRONE_GITHUB_SECRET=${DRONE_GITHUB_SECRET}
      - DRONE_SECRET=${DRONE_SECRET}
      - DRONE_OPEN=true
      - DRONE_ADMIN=guiguan,joeyzhao0113
      - DRONE_TIMEOUT=120m
      - DRONE_TIMEOUT_INACTIVITY=120m

  drone-agent:
    image: drone/drone:latest
    command: agent
    restart: always
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_SERVER=ws://drone-server:8000/ws/broker
      - DRONE_SECRET=${DRONE_SECRET}
      - DRONE_TIMEOUT=120m
      - DRONE_TIMEOUT_INACTIVITY=120m
      - DRONE_MAX_PROCS=5

volumes:
  drone-server-data:
    external: true

Adding SSH_PRIVATE_KEY

drone secret add --repository SouthbankSoftware/${REPO_NAME} --name SSH_PRIVATE_KEY --value="$(cat ${KEY_PATH})"

ngrok

ngrok http -subdomain=cienvy -region au 8000

Development

API

You can make use of CIEnvy either through its REST API or provided CIEnvy Client

REST API

  1. Access CIEnvy's Swagger UI: http://localhost:3030/docs
  2. Authenticate with SBS Developer Credential by POSTing following JSON to /authentication

     {
       "email":"${DEVELOPER_EMAIL}",
       "password":"${DEVELOPER_PASSWORD}",
       "payload":{
         "userId": null
       }
     }
    
  3. Get the returned accessToken, and use a Chrome plugin, such as Modify Headers, to modify request header: Authorization: Bearer ${accessToken}

CIEnvy Client

This is a node based client lib. You can find more details from here

Documentation

Testing

yarn test

Folder Structure

cienvy
├── config: yaml configuration files
├── data: databases and temp data
│   ├── template: database templates
│   ├── *.db: databases
│   └── workspace: cienvy host level data
├── docs: auto-generated source code documentation
├── misc: miscellaneous stuffs
├── node_modules: node dependencies
├── public: static web hosting files
├── src: source code
│   ├── controllers: service controllers
│   ├── hooks: Feathers global hooks
│   ├── middleware: Feathers middleware
│   ├── services: Feathers services
│   └── app/index.js: entrypoint
└── tests: unit test code
Docker Pull Command
Owner
southbanksoftware
Source Repository