Skip to content

Commit

Permalink
Add build configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-helmich committed May 1, 2017
1 parent adb5c74 commit 4e8febc
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
stages:
- build
- dockerbuild
- publish
- deploy

cache:
paths:
- dist
- node_modules

build:frontend:
image: node:6
stage: build
before_script:
- npm install -g typescript webpack
- npm install
script:
- webpack

dockerbuild:frontend:
image: docker:17.04.0-ce
stage: dockerbuild
dependencies:
- build:frontend
script:
- docker image build -t myevents/frontend:$CI_COMMIT_REF_NAME .
only:
- tags

publish:
image: docker:17.04.0-ce
stage: publish
dependencies:
- dockerbuild:frontend
before_script:
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
script:
- docker image push myevents/frontend:$CI_COMMIT_REF_NAME
only:
- tags

deploy:
image: alpine:3.5
stage: deploy
environment: production
before_script:
- apk add --update openssl
- wget -O /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.6.1/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl
- echo "$KUBE_CA_CERT" > ca.crt
- kubectl config set-credentials gitlab-ci --token="${KUBE_TOKEN}"
- kubectl config set-cluster your-cluster --server=https://your-cluster.example --certificate-authority=ca.crt
- kubectl config set-context your-cluster --cluster=your-cluster --user=gitlab-ci
- kubectl config use-context your-cluster
script:
- kubectl set image deployment/eventservice api=myevents/frontend:${CI_COMMIT_REF_NAME}
only:
- tags
31 changes: 31 additions & 0 deletions .travis-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
sudo: required
language: node
services:
- docker
node_js:
- 6
env:
- SERVICE=frontend
- CGO_ENABLED=0
- DOCKER_USER=<your-dockerhub-user>

install:
- npm install
- npm install -g typescript webpack
- curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.6.1/bin/linux/amd64/kubectl
- chmod +x kubectl
- echo "${KUBE_CA_CERT}" > ca.crt
- ./kubectl config set-credentials travis-ci --token="${KUBE_TOKEN}"
- ./kubectl config set-cluster your-cluster --server=https://your-cluster.example --certificate-authority=ca.crt
- ./kubectl config set-context your-cluster --cluster=your-cluster --user=travis-ci --namespace=default
- ./kubectl config use-context your-cluster
script:
- webpack
- docker image build -t ${DOCKER_USER}/myevents_${SERVICE}:${TRAVIS_BRANCH} src/${SERVICE}

after_success:
- if [ -n "${TRAVIS_TAG}" ] ; then
docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}";
docker push ${DOCKER_USER}/myevents_${SERVICE}:${TRAVIS_BRANCH};
./kubectl set image deployment/${SERVICE} frontend=${DOCKER_USER}/myevents_${SERVICE}:${TRAVIS_BRANCH}
fi

0 comments on commit 4e8febc

Please sign in to comment.