Skip to content

Instantly share code, notes, and snippets.

@yetanotherchris
Created February 1, 2017 21:52
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save yetanotherchris/7be82856f3240776a880d3bf540bf844 to your computer and use it in GitHub Desktop.
Save yetanotherchris/7be82856f3240776a880d3bf540bf844 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 1234@5678.com -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