J. Pichardo
J. Pichardo

Reputation: 3115

Testing ASP.NET Core Docker Container with Travis CI

So I've configured my .travis.yml to build and test my ASP.NET Core project, but now I've to configure it to run in docker. So far so good, I've the Dockerfile for the build, but then I started to figure:

UPDATE:

The Dockerfile is:

FROM microsoft/dotnet:latest
ARG source=.
WORKDIR /usr/src/project

COPY $source .

RUN dotnet restore

EXPOSE 5000
CMD dotnet build **/*/project.json

And the .sh is:

#!/bin/bash
cd test/
for D in `find ./ -maxdepth 1 -type d`
do
        if [ -a ./project.json ]
        then
            ( cd ${D}; dotnet test;)
        fi
done

Any suggestions are greatly appreciated.

Upvotes: 1

Views: 426

Answers (1)

J. Pichardo
J. Pichardo

Reputation: 3115

So I decided that the docker build and publish should only be done if the build and test succeeded

.travis.yml

language: csharp

sudo: required


solution: Solution.sln


mono: none

dotnet: 1.0.0-preview2-1-003177


services:

    - docker


install:

    - npm install -g bower

    - npm install -g gulp


before_script:

    - chmod a+x ./scripts/test.sh


script:

    - dotnet restore && dotnet build **/*/project.json

    - ./scripts/test.sh --quite verify

    - if [ "$TRAVIS_BRANCH" == "master" ] ; then 

      dotnet publish --no-build src/Main -o publish/ ;

      docker build -t project . ;

      fi

    

after_success: 

    - if [ "$TRAVIS_BRANCH" == "master" ] ; then 

      /* Push to docker repo */

      fi 

Upvotes: 4

Related Questions