Skip to content

Commit

Permalink
updates circleci to push to dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
runeanielsen committed Aug 12, 2020
1 parent 3e4616e commit fe034c2
Showing 1 changed file with 69 additions and 3 deletions.
72 changes: 69 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,75 @@ executors:
dotnet-core-sdk:
docker:
- image: mcr.microsoft.com/dotnet/core/sdk:3.1
docker-publisher:
environment:
IMAGE_NAME: openftth/api-gateway
docker:
- image: circleci/buildpack-deps:stretch

jobs:
build-app:
executor: dotnet-core-sdk
steps:
- checkout
- run:
name: Apt update
command: apt-get update;
- run:
name: Restore
command: dotnet restore
- run:
name: Build
command: dotnet build
command: dotnet build -c Release

test-app:
executor: dotnet-core-sdk
steps:
- checkout
- run:
name: Apt update
command: apt-get update;
- run:
name: Test
command: dotnet test

build-docker-image:
executor: docker-publisher
steps:
- checkout
- setup_remote_docker
- run:
name: Build Docker image
command: |
docker build -t $IMAGE_NAME:latest .
- run:
name: Archive Docker image
command: docker save -o image.tar $IMAGE_NAME
- persist_to_workspace:
root: .
paths:
- ./image.tar

docker-publish-image:
executor: docker-publisher
steps:
- attach_workspace:
at: /tmp/workspace
- setup_remote_docker
- run:
name: Load archived Docker image
command: docker load -i /tmp/workspace/image.tar
- run:
name: Publish Docker Image to Docker Hub
command: |
echo "$DOCKER_ACCESSTOKEN" | docker login -u $DOCKER_LOGIN --password-stdin
IMAGE_TAG=${CIRCLE_TAG}
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_TAG
docker push $IMAGE_NAME:latest
docker push $IMAGE_NAME:$IMAGE_TAG
workflows:
build-test-publish:
build-test-upload_image:
jobs:
- build-app:
filters:
Expand All @@ -34,4 +83,21 @@ workflows:
- build-app
filters:
tags:
only: /.*/
only: /.*/
- build-docker-image:
requires:
- test-app
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- docker-publish-image:
context: docker
requires:
- build-docker-image
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/

0 comments on commit fe034c2

Please sign in to comment.