X
Closing this message and/or accessing our website tells us you are happy to receive all cookies on the ClearPeople website.
However, if you would like to, you can change your cookies settings at any time.
Our Senior Sitecore Developer's advice to find "docker-compose.vs.debug.yml"

While I was learning about Docker with Visual Studio 2017 I was kind of busy with something that resulted way easier that I had thought. Below I have written a few lines that can hopefully help someone else. 

 

In the training from Pluralsight “Introduction to Docker on Windows with Visual Studio 2017“ by Marcel de Vries, as in other publications like this and this one, you can see how, by adding support for Docker to a Visual Studio 2017 project, the following elements in the solution appear: 

 

  • New Visual Studio Project named “docker-compose” with the following files:
    • docker-compose.yml
    • docker-compose.override.yml
    • docker-compose.vs.debug.yml
    • docker-compose.vs.release.yml
  • New files within the project where support has been added for Docker:
    • Dockerfile
    • .dockerignore

The files docker-compose.vs.debug.yml” and “docker-compose.vs.release.yml” are very useful to define specific container characteristics for the development and production environments. For example, it could be interesting to use “volume” for the website folder in IIS when developing, facilitating to overwrite the files in this phase, and later, when we are going to do a release, the same folder can be introduced in the container, so it facilitates its deployment. 

 

When adding Docker support to an existing VS solution, I was quite surprised to see that the files “docker-compose.vs.debug.yml”, and “docker-compose.vs.release.yml” weren’t created. The version of Visual Studio 2017 that I used was 15.5.7.

 

On the other hand, in the “Output” window in Visual Studio, when compiling the project “docker-compose.dcproj” the following lines appeared:

 

docker-compose -f “c:\Docker\Sitecore82TDS\docker-compose.yml” -f “c:\Docker\Sitecore82TDS\docker-compose.override.yml” -f “c:\Docker\Sitecore82TDS\obj\Docker\docker-compose.vs.debug.g.yml” -p dockercompose6697759991785308464 config

docker-compose -f “c:\Docker\Sitecore82TDS\docker-compose.yml” -f “c:\Docker\Sitecore82TDS\docker-compose.override.yml” -f “c:\Docker\Sitecore82TDS\obj\Docker\docker-compose.vs.debug.partial.g.yml” -p dockercompose6697759991785308464 kill 

docker-compose -f “c:\Docker\Sitecore82TDS\docker-compose.yml” -f “c:\Docker\Sitecore82TDS\docker-compose.override.yml” -f “c:\Docker\Sitecore82TDS\obj\Docker\docker-compose.vs.debug.partial.g.yml” -p dockercompose6697759991785308464 down –rmi local –remove-orphans 

 

There are two details in these lines that confused me: 

  • It seems that VS2017 is using the name “docker-compose.vs.debug.partial.g.yml” or “docker-compose.vs.debug.g.yml” instead of “docker-compose.vs.debug.yml“. 
  • The location of both files in within “obj/Docker”.  

In the first instance I though that VS had changed the name of the file and its location. Moreover, there are two folders with the path “obj/Docker”. One is being created within the original project (where support has been added for Docker) and the other is created by VS from scratch (where the solution file *.sln is). The one being used by VS to generate the container is the second one, where you can find the following files:  

  • docker-compose.vs.debug.g.yml 
  • docker-compose.vs.debug.partial.g.yml 

After doing various tests I noticed that VS is generating both files in each compilation (“Build”). Actually, you can’t use any of these to add to the container specific development changes.   

 

Finally, the solution was the simplest one. You just need to manually create the files “docker-compose.vs.debug.yml”, and “docker-compose.vs.release.yml” in the folder where the project “docker-compose.dcproj” is also saved. Only the existence of it is enough for VS to detect the files and to use them, although I prefer to add them also to the project docker-compose.dcproj”. The steps are as follows: 

  1. In VS2017, right-click on the project “docker-compose” and then click on “Unload Project”. 
  2. Right-click again on the project “docker-compose” and this time choose “Edit ‘docker-compose.dcproj'”
  3. Search for the following lines in the file of the project:
    <ItemGroup>
    <None Include=”docker-compose.override.yml”>
    <DependentUpon>docker-compose.yml</DependentUpon>
    </None>
    <None Include=”docker-compose.yml” />
    </ItemGroup>
  4. Replace the previous lines with the following ones:
    <ItemGroup> 
    <None Include=”docker-compose.vs.debug.yml“
    <DependentUpon>docker-compose.yml</DependentUpon> 
    </None> 
    <None Include=”docker-compose.vs.release.yml“
    <DependentUpon>docker-compose.yml</DependentUpon> 
    </None> 

    <None Include=”docker-compose.override.yml”> 
    <DependentUpon>docker-compose.yml</DependentUpon> 
    </None> 
    <None Include=”docker-compose.yml” /> 
    </ItemGroup>
  5. Save the file “docker-compose.dcproj” and close it.
  6. Create two text files and name them “docker-compose.vs.debug.yml”, and “docker-compose.vs.release.yml” in the same folder where the project “docker-compose.dcproj” is saved.
  7. In VS2017, load the project “docker-compose” again by double-clicking on it’s name and choose “Reload Project”  

Once that’s done, VS detects the new files and directly uses them as you can see in the following line taken from the Output window in VS:  

docker-compose -f “c:\Docker\Sitecore82TDS\docker-compose.yml” -f “c:\Docker\Sitecore82TDS\docker-compose.override.yml” -f “c:\Docker\Sitecore82TDS\docker-compose.vs.debug.yml” -p dockercompose6697759991785308464 config 

 

More information about Docker to come next week in my new blog!

 

Please also read my previous blog about Sitecore demo in a Docker Container.

Author bio

Benjamin Moles
Benjamin Moles
.NET Developer
I'm a passionate .NET and SQL developer. I've worked with a broad variety of technologies and I am currently contributing to the success of ClearPeople's Sitecore projects. Beside IT stuff, I love to spend time with family and play with remote-controlled helicopters.

Comments


comments powered by Disqus

Related Articles

Sign up to our Newsletter

Every now and then, we'd like to send you information that delivers, develops and promotes our products and services that are relevant to you. Submitting your details tells us that you're OK with this and you also agree to our Privacy & Cookies policy. You can, of course, opt out of these communications at any time.