Question: I opened VSCode and was presented with a notification that there was a conflict between two versions of a file. I followed the prompts and got a side-by-side comparison of two versions. I clicked the button that accepts the newer version, believing that VSCode had correctly inferred which version was newer. It had not, and I lost a significant number of changes to the file. Is there a cached copy of the other version anywhere?

Thank you!

ps - I seem to have failed to actually commit the changes in git as well. Not sure how that happened.

Answer: 
**Question 1: What is the use of WORKDIR /app on line number 2?**

This defines your current working directory. Following commands will by default be run from that location and relative paths will start there.

Example with the following file structure:

```
/app/
  - README.md
  - folder1/
       - some.txt

```

```
WORKDIR /app
RUN ls

```

will print

```
folder1
README.md

```

and

```
WORKDIR /app/folder1
RUN ls

```

will print

```
some.txt

```

**Question 2: Why are we setting WORKDIR /src for the SDK image and not WORKDIR /app?**

See the answer to Question 1. The following `COPY` and `dotnet restore` command are executed in the `/src` source directory. (The build is done from the `/src` directory and the created artifact in `/app/publish` is later copied to the `/app` directory in the last stage, to be executed from that `/app` directory.)

**Question 3: Are paths in copy commands relevant to Dockerfile or Docker-compose.yml file?**

Copy takes two paths. The first one references the source (a file or folder from the context the docker image is build from) and the second one references the destination (a file order folder in your resulting docker image.) Hence these paths are usually only specific to the Dockerfile and independent from your docker-compose project.

However in your case the context of your docker image build is defined in the docker-compose.yml here:

```
build:
      context: .
      dockerfile: Services/Orders/Dockerfile

```

and therefore the context of your docker image image build seems to be the directory where your docker-compose.yml is located. You could build the same image though if you just run `docker build -f Services/Orders/Dockerfile .` in that folder. (It is not docker-compose specific)

Therefore you should find `Orders.csproj` in `./Services/Orders/` starting from the directory your docker-compose.yml is located in. This file is than copied to `/src/Services/Orders/Orders.csproj` in your second build stage. (The `/src` can be commited in the `COPY` statement as it is a relative path starting from your current working directory, which is defined in the line above. - See Question 1)
The reason we use "multi-stage" builds and use several images and copy files to continue instead of just sequentially carrying out steps is mainly due to trying to keep the image size small. Although disk space may be adequate, the following factors can also be relevant:

1. Build/deploy times. Larger images mean longer continuous integration, the more time will be spent waiting for these operations to complete.
2. Start-up time. When running your application in production the longer the download takes, the longer it will be before the new container can be up and running.

Therefore using a multi-stage approach as below we are able to omit the sdk which is much bigger and is only needed for building not running the application:

[![enter image description here](https://i.stack.imgur.com/TSUDP.png)](https://i.stack.imgur.com/TSUDP.png)

[![Console app with build](https://i.stack.imgur.com/9k2Wt.png)](https://i.stack.imgur.com/9k2Wt.png)

[![Console app after transfer](https://i.stack.imgur.com/CMIH5.png)](https://i.stack.imgur.com/CMIH5.png)

Notice that we use ENTRYPOINT in the second image as the "dotnet run" is only available in the sdk so we make a minor adjustment to just directly run the .dll to get the same outcome.