-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
40 lines (34 loc) · 1.43 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
image: docker:latest
services:
- docker:dind
before_script:
- docker info
variables:
DOCKER_HOST: tcp://localhost:2375
build-branch:
stage: build
only:
- branches
- master
script:
- docker run --rm=true -v $PWD:/go/src/krak8s golang:1.8 bash -c "cd /go/src/krak8s; make containerprep"
- docker login -u ${REGISTRY_USERNAME} -p ${REGISTRY_PASSWORD} ${REGISTRY_HOST}
- docker build -t ${REGISTRY_HOST}/${REGISTRY_IMAGE_NAME}:${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA} .
- docker push ${REGISTRY_HOST}/${REGISTRY_IMAGE_NAME}:${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
build-tag:
stage: build
only:
- tags
script:
- docker run --rm=true -v $PWD:/go/src/krak8s golang:1.8 bash -c "cd /go/src/krak8s; make containerprep"
- docker login -u ${REGISTRY_USERNAME} -p ${REGISTRY_PASSWORD} ${REGISTRY_HOST}
- docker build -t ${REGISTRY_HOST}/${REGISTRY_IMAGE_NAME}:${CI_COMMIT_TAG} .
- docker push ${REGISTRY_HOST}/${REGISTRY_IMAGE_NAME}:${CI_COMMIT_TAG}
deploy-tag:
stage: deploy
only:
- tags
script:
- echo ${KUBECONFIG} |base64 -d > ${PWD}/kubeconfig
- docker login -u ${KUBECTL_USERNAME} -p ${KUBECTL_PASSWORD} ${KUBECTL_HOST}
- docker run --rm=true -v ${PWD}/kubeconfig:/root/.kube/config --entrypoint /kubectl ${KUBECTL_HOST}/${KUBECTL_IMAGE}:${KUBECTL_TAG} --namespace ${DEPLOYMENT_NAMESPACE} set image deployment/${DEPLOYMENT_NAME} ${CONTAINER_NAME}=${REGISTRY_HOST}/${REGISTRY_IMAGE_NAME}:${CI_COMMIT_TAG}