Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET Core custom build image and Docker hub image push #2870

Closed
johnmckinzie opened this issue Aug 11, 2016 · 8 comments
Closed

.NET Core custom build image and Docker hub image push #2870

johnmckinzie opened this issue Aug 11, 2016 · 8 comments
Assignees

Comments

@johnmckinzie
Copy link

I don't really know if this is a bug, b/c I know there are some restrictions on the custom build images. I'm trying to build my project using the following custom image:

https://hub.docker.com/r/microsoft/dotnet/

I can successfully build the project using the file below:

language: none

build:
  pre_ci_boot:
    image_name: microsoft/dotnet
    image_tag: 1.0.0-preview2-sdk
    pull: true
    options: "-e HOME=/root"

  ci:
    - dotnet restore
    - cd src/DibblerApi
    - dotnet build
    - dotnet publish

  push:
    - docker push dibbler/dibbler-api:$BRANCH.$BUILD_NUMBER

integrations:
  hub:
    - integrationName: dockerhub
      type: docker
      branches:
        only:
          - master

However, when I get tot the push step, I get the following error:

docker push dibbler/dibbler-api:$BRANCH.$BUILD_NUMBER
The push refers to a repository [docker.io/dibbler/dibbler-api] (len: 1)
Repository does not exist: dibbler/dibbler-api

I can successfully push to that repo form my local machine using the same credentials.

I would be nice to now that it is or is not tied to the custom image.

@rageshkrishna
Copy link
Contributor

@johnmckinzie The error message Repository does not exist typically shows up when the image you're trying to push doesn't exist locally. Is your build doing a docker build to create the image?

@johnmckinzie
Copy link
Author

johnmckinzie commented Aug 11, 2016

Is your build doing a docker build to create the image?

Are you talking about the CI image or the image I'm trying to build and push?

So since I'm building in a custom container, I should use the "push" commanded to build the Docker image on the host machine not in the Docker container, correct? If that's true, the following is the only example I found in the documentation:

build:
  push:
    - docker push manishas/sample-node:$BRANCH.$BUILD_NUMBER

I went ahead and added a docker build command to the the push: step and now I get the following error:

docker build -t dibbler/dibbler-api:$BRANCH.$BUILD_NUMBER . 0s  
     unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /root/Dockerfile: no such file or directory

Here is my latest shippable.yml:

language: none

build:
  pre_ci_boot:
    image_name: microsoft/dotnet
    image_tag: 1.0.0-preview2-sdk
    pull: true
    options: "-e HOME=/root"

  ci:
    - dotnet restore
    - cd src/DibblerApi
    - dotnet build
    - dotnet publish

  push:
    - docker build -t dibbler/dibbler-api:$BRANCH.$BUILD_NUMBER .
    - docker push dibbler/dibbler-api:$BRANCH.$BUILD_NUMBER

integrations:
  hub:
    - integrationName: dockerhub
      type: docker
      branches:
        only:
          - master

@manishas
Copy link
Contributor

@johnmckinzie let me clarify your scenario:

  • You want to use a custom image microsoft/dotnet for your build.
  • After your build is complete, you want to build a new image and push it to Docker Hub.

Do you have the Dockerfile for dibbler/dibbler-api at the root of your repository? That is where we look for the file when you run a docker build command in your yml.

@johnmckinzie
Copy link
Author

@manishas You are correct in your understanding. That is what I'm trying to achieve.

With regards to the Dockerfile, it is actually in a sub-directory (src/DibblerApi) because the repo contains two projects, the application and the unit test project. This is a common structure in the .NET Core community.

@rageshkrishna
Copy link
Contributor

@johnmckinzie Please move whatever is in your push section in to ci. Also, you'll need to point to the correct Dockerfile location. By default, we're at the root of the repository when the build starts. If I've understood your directory structure correctly, you'll need something like this:

cd src/DibblerApi && docker build -t dibbler/dibbler-api:$BRANCH.$BUILD_NUMBER .

@rageshkrishna
Copy link
Contributor

I just noticed you're already moving to src/DibblerApi earlier in the yml file. Moving the docker build and push commands to the ci section of the YML file should make everything work.

@manishas
Copy link
Contributor

closing this since it appears to be resolved. @johnmckinzie please let us know if you need help with anything else.

@cdroulers
Copy link

If anyone ever needs another example of shippable.yml for dotnet core, here is a blog post about my migration to the MSBuild SDK with .NET Core 1.0.1 SDK. http://geeks.akinox.com/2017/03/17/migrating-dotnetcore/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants