Last active
October 25, 2018 14:08
-
-
Save devfelipereis/067f1d834682b6c9a92e9acaf45d584f to your computer and use it in GitHub Desktop.
gitlab ci deploy rancher k8s example (commit sha)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: docker:latest | |
services: | |
- docker:dind | |
stages: | |
- build | |
- deploy | |
variables: | |
DOCKER_DRIVER: overlay | |
IMAGE_TAG: $CI_REGISTRY_IMAGE | |
build: | |
stage: build | |
only: | |
- master | |
script: | |
- docker build -f Dockerfile.prod -t $IMAGE_TAG:${CI_COMMIT_SHA:0:8} . | |
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY | |
- docker push $IMAGE_TAG:${CI_COMMIT_SHA:0:8} | |
deploy_production: | |
stage: deploy | |
image: devfelipereis/rancher-cli-k8s:latest | |
environment: | |
name: production | |
url: https://your-app.com | |
when: on_success | |
only: | |
- master | |
script: | |
- rancher login $RANCHER_SERVER_URL --token $RANCHER_API_TOKEN --context $RANCHER_PROJECT_ID | |
- rancher kubectl --namespace=$RANCHER_PROJECT_NAMESPACE set image deployment/$DEPLOYMENT_NAME $DEPLOYMENT_NAME=$IMAGE_TAG:${CI_COMMIT_SHA:0:8} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment