Skip to content

Instantly share code, notes, and snippets.

@wescleymatos
Forked from yetanotherchris/ .gitlab-ci.yml
Created January 12, 2018 12:21
Show Gist options
  • Save wescleymatos/0374ba464bdc43f85a1d49249af2bd08 to your computer and use it in GitHub Desktop.
Save wescleymatos/0374ba464bdc43f85a1d49249af2bd08 to your computer and use it in GitHub Desktop.
.NET Core continous integration with Docker, Kubernetes, Gitlab and Google Cloud
# http://docs.gitlab.com/ce/ci/docker/using_docker_build.html#using-the-gitlab-container-registry
# The docker tag is the first 6 letters of the Git commit id
job_build_dotnet:
stage: build
image: microsoft/dotnet:latest
script:
- dotnet restore
- dotnet publish src/MyProject.Web -c Release
artifacts:
expire_in: 12 hrs
paths:
- src/MyProject.Web/bin/Release/netcoreapp1.1/publish/
job_build_docker:
stage: deploy
image: docker:latest
services:
- docker:dind
script:
- export DOCKER_VERSION=$(echo "$CI_BUILD_REF" | cut -c 1-6)
- echo "$GOOGLE_AUTH_JSON" > google-cloud.json
- cd src/MyProject.Web && docker build -t gcr.io/my-kube-project/MyProject-web:$DOCKER_VERSION .
- cd ../../ && docker login -e [email protected] -u _json_key -p "$(cat google-cloud.json)" https://gcr.io
- docker push gcr.io/my-kube-project/MyProject-web:$DOCKER_VERSION
dependencies:
- job_build_dotnet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment