Skip to content

Commit

Permalink
Backporting github changed to gitlabs
Browse files Browse the repository at this point in the history
  • Loading branch information
emeka committed Sep 19, 2019
1 parent b42265a commit a3639a0
Show file tree
Hide file tree
Showing 4 changed files with 881 additions and 1 deletion.
205 changes: 205 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@

version: 2.1

executors:
docker-image-golang:
environment:
PROJECT_ROOT_FOLDER: ~/project
docker:
- image: golang:1.11
docker-publisher:
environment:
PROJECT_ROOT_FOLDER: ~/project
CONTAINER_IMAGE_NAME: proxeus/proxeus-core
docker:
- image: circleci/buildpack-deps:stretch

jobs:
validate:
executor: docker-image-golang
steps:
- checkout
- restore_cache:
keys:
- go-vendor-v1-{{ .Branch }}
- run:
command: make link-repo
- run:
command: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- run:
command: go get golang.org/x/tools/cmd/goimports
- run:
command: |
cd /go/src/git.proxeus.com/core/central
dep ensure -v
- run:
command: chmod -R +x ./build
- run:
command: |
cd /go/src/git.proxeus.com/core/central
make fmt
- run:
command: |
cd /go/src/git.proxeus.com/core/central
make validate
- save_cache:
key: go-vendor-v1-{{ .Branch }}
paths:
- vendor/

test:
executor: docker-image-golang
steps:
- checkout
- restore_cache:
keys:
- go-vendor-v1-{{ .Branch }}
- run:
command: chmod -R +x ./build
- run:
command: make link-repo
- run:
command: |
cd /go/src/git.proxeus.com/core/central
make test
- save_cache:
key: go-vendor-v1-{{ .Branch }}
paths:
- vendor/

build-ui:
docker:
- image: node:10
steps:
- checkout
- restore_cache:
keys:
- yarn-v1-{{ .Branch }}
- run:
command: chmod -R +x ./build
- run:
command: make ui
- save_cache:
key: yarn-v1-{{ .Branch }}
paths:
- ui/.yarn/
- ui/node_modules/
- ui/core/node_modules/
- ui/wallet/node_modules/
- persist_to_workspace:
root: .
paths:
- ./artifacts/dist

build-go:
executor: docker-image-golang
steps:
- checkout
- attach_workspace:
at: ~/project/
- restore_cache:
keys:
- go-vendor-v1-{{ .Branch }}
- run:
command: chmod -R +x ./build
- run:
name:
command: make link-repo
- run:
name:
command: |
cd /go/src/git.proxeus.com/core/central
make server-docker
- save_cache:
key: go-vendor-v1-{{ .Branch }}
paths:
- vendor/
- persist_to_workspace:
root: .
paths:
- ./artifacts/server-docker

build-docker:
executor: docker-publisher
steps:
- checkout
- attach_workspace:
at: ~/project/
- setup_remote_docker
- run:
name: Build Docker image
command: |
docker build -f Dockerfile -t $CONTAINER_IMAGE_NAME:latest -t $CONTAINER_IMAGE_NAME .
- run:
name: Archive Docker image
command: docker save -o image.tar $CONTAINER_IMAGE_NAME
- persist_to_workspace:
root: .
paths:
- image.tar

publish-latest:
executor: docker-publisher
steps:
- attach_workspace:
at: /tmp/workspace
- setup_remote_docker
- run:
name: Load archived Docker image
command: docker load -i /tmp/workspace/image.tar
- run:
name: Publish Docker Image to Docker Hub
command: |
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
docker push $CONTAINER_IMAGE_NAME
publish-demo:
executor: docker-publisher
steps:
- attach_workspace:
at: /tmp/workspace
- setup_remote_docker
- run:
name: Load archived Docker image
command: docker load -i /tmp/workspace/image.tar
- run:
name: Tag docker image
command: docker tag $CONTAINER_IMAGE_NAME $CONTAINER_IMAGE_NAME:demo
- run:
name: Publish Docker Image to Docker Hub
command: |
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
docker push $CONTAINER_IMAGE_NAME:demo
workflows:
version: 2
build-master:
jobs:
- validate
- test:
requires:
- validate
- build-ui:
requires:
- test
- build-go:
requires:
- build-ui
- build-docker:
requires:
- build-ui
- build-go
- publish-latest:
requires:
- build-docker
- hold:
type: approval
requires:
- build-docker
- publish-demo:
requires:
- hold
filters:
branches:
only: master
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ variables:
DOCKER_HOST: tcp://localhost:2375
DOCKER_DRIVER: overlay2
CONTAINER_IMAGE_NAME: eu.gcr.io/blockfactory-01/proxeus-platform
PROJECT_ROOT_FOLDER: /builds/core/central

stages:
- validate
Expand Down
Loading

0 comments on commit a3639a0

Please sign in to comment.