Understanding docker-compose of VS2017 webform application

Viewed 351

I'm creating a Webform application that I try to containerize. I use VS2017, create the default webform app, and add docker support.

If I F5 the application, it's working (hopefully)

The "add docker support" adds many files :

1) a Dockerfile, with

FROM microsoft/aspnet:4.6.2
ARG source
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .

I understand it's based on the aspnet:4.6.2 image and that it copy the files from obj/docker/publish to put them in the container.

My problem is that I have no files published on this directory. Of course if I docker build, I have an error (it can't find files in obj/docker/publish). Remember, with F5 it's working.

But there's additionnal files.

2) Docker-compose.yml :

version: '3'

services:
  legacywebapp:
    image: legacywebapp
    build:
      context: .\LegacyWebApp
      dockerfile: Dockerfile

If I understand well, it creates a legacywebapp services based on the dockerfile. The one that is not working, and still no "obj/docker/publish"

3) docker-compose.override.yml with :

version: '3'

services:
  legacywebapp:
    ports:
      - "80"
networks:
  default:
    external:
      name: nat

Ok, I assume it exposes the port 80 (why not in the first file ? but anyway, for modularity it's better I suppose).

If I try

docker-compose -f .\docker-compose.yml -f .\docker-compose.override.yml build

of course I have an error :

Step 4/4 : COPY ${source:-obj/Docker/publish} .
ERROR: Service 'legacywebapp' failed to build: COPY failed: GetFileAttributesEx \\?\C:\windows\TEMP\docker-builder798755009\obj\Docker\publish: The system cannot find the file specified.

Why is it working when I F5 in visual studio ? Let's look in the build output of VS, I can see the command line :

docker-compose -f "C:\Users\...\docker-compose.yml" -f "C:\Users\...\docker-compose.override.yml" -f "C:\Users\...\obj\Docker\docker-compose.vs.debug.g.yml" -p dockercompose15539612722162891187 up -d --build

So, there's another file, I suppose for debugging :

4) docker-compose.vs.debug.g.yml

version: '3'

services:
  legacywebapp:
    image: legacywebapp:dev
    build:
      args:
        source: obj/Docker/empty/
    volumes:
      - C:\Users\...\LegacyWebApp:C:\inetpub\wwwroot
      - C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Remote Debugger:C:\remote_debugger:ro
    labels:
      com.microsoft.visualstudio.debuggee.program: "C:\\app\\bin/LegacyWebApp.dll"
      com.microsoft.visualstudio.debuggee.workingdirectory: "C:\\app"

And again, no obj/docker/publish. What is the obj/Docker/empty/ ?

How can I build correctly the image ? For example if I want to publish it in a private repository...

0 Answers
Related