Updated 04. Setting eShopOnContainer solution up in a Mac, VS for Mac or with CLI environment (dotnet CLI, Docker CLI and VS Code) (markdown)
parent
935eaaff20
commit
e0c28f17fb
@ -16,6 +16,9 @@ If your projects are placed within the /Users folder, you don't need to configur
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Docker Multi-stage support
|
||||||
|
Since December 2017, eShopOnContainers supports [Docker Multi-stage](https://blogs.msdn.microsoft.com/stevelasker/2017/09/11/net-and-multistage-dockerfiles/), therefore, the steps in order to compile the .NET apps/projects before creating the Docker images can now be performed with a single command based on "docker-compose build" or "docker build".
|
||||||
|
|
||||||
|
|
||||||
# Option A: Use Visual Studio for Mac
|
# Option A: Use Visual Studio for Mac
|
||||||
The quickest path to get eShopOnContainers running on your Mac is by using VS for Mac which will install most of the pre-requisites you need.
|
The quickest path to get eShopOnContainers running on your Mac is by using VS for Mac which will install most of the pre-requisites you need.
|
||||||
@ -99,10 +102,69 @@ And by typing `docker ps` you can see the containers running in Docker. The infr
|
|||||||
|
|
||||||
1. [Docker for Mac](https://docs.docker.com/docker-for-mac/install/). You should already have this.
|
1. [Docker for Mac](https://docs.docker.com/docker-for-mac/install/). You should already have this.
|
||||||
1. A Git client. The [git-scm site](https://git-scm.com/download/gui/mac) maintains a great list of clients.
|
1. A Git client. The [git-scm site](https://git-scm.com/download/gui/mac) maintains a great list of clients.
|
||||||
1. [Node.js](http://nodejs.org). The stable channel is fine as well.
|
1. (OPTIONAL) NPM installed with [Node.js](http://nodejs.org). The stable channel is fine as well.
|
||||||
1. Bower ($ sudo npm install -g bower) needed by the MVC web app.
|
1. (OPTIONAL) Bower ($ sudo npm install -g bower) needed by the MVC web app.
|
||||||
1. [.NET Core and SDK](http://dot.net). Install the SDK and runtime.
|
1. [.NET Core and SDK](http://dot.net). Install the SDK and runtime.
|
||||||
|
|
||||||
|
### Local installation of NPM/Node, Bower and .NET Core SDK are not required when using Docker Multi-Stage
|
||||||
|
|
||||||
|
The SDKs and dependencies like NPM, Bower and even .NET Core SDK are optional because when building through Docker Multi-Stage it will be using the dependencies available within the ASP.NET Core build image, not the installed software on the local machine/PC.
|
||||||
|
However, if you will be developing .NET apps in the Mac or customizing eShopOnContainers, it is recommended to install all the dependencies locally, as well.
|
||||||
|
|
||||||
|
# Compile the application's projects and build the Docker images with a single command thanks to Docker Multi-Stage
|
||||||
|
|
||||||
|
The recommended approach is to build the .NET application/microservices bits and Docker images with a single command based on [Docker Multi-Stage](https://blogs.msdn.microsoft.com/stevelasker/2017/09/11/net-and-multistage-dockerfiles/) by simply running the following commands within the solution's root folder:
|
||||||
|
|
||||||
|
Move to the root folder of the solution:
|
||||||
|
|
||||||
|
`cd YourPath\eShopOnContainers\`
|
||||||
|
|
||||||
|
Then, run the following docker command:
|
||||||
|
|
||||||
|
`docker-compose build`
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The first time you run this command it'll take some more additional time as it needs to pull/download the aspnet-build image with the SDKs, so it'll take its time.
|
||||||
|
|
||||||
|
It should take a few minutes to compile all the .NET Core projects plus the SPA application (Angular/TypeScript/JavaScript) which has additional processes and dependencies using NPM.
|
||||||
|
|
||||||
|
- When the `docker-compose build` command finishes, you can check out with Docker CLI the images created by typing in the PowerShell console the command:
|
||||||
|
|
||||||
|
`docker images`
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Those Docker images you see are the ones you have available in your local image repository in your machine.
|
||||||
|
You might have additional images, but at least, you should see the the custom images starting with the prefix "eshop" which is the name of the image repo. The rest of the images that are not starting with "eshop" will probably be official base-images like the microsoft/aspnetcore or the SQL Server for Linux images, etc.
|
||||||
|
|
||||||
|
# Deploy the containers into the local Docker host
|
||||||
|
|
||||||
|
With a single command you can deploy the whole solution into your local Docker host by just executing the following:
|
||||||
|
|
||||||
|
`docker-compose up`
|
||||||
|
|
||||||
|
<img src="img/cli-windows/docker-compose-up-1.png">
|
||||||
|
|
||||||
|
Note that the first time you try to run the application (with docker run or docker-compose) it detects that it needs a few related infrastructure images, like the SQL Server image, Redis image, RabbitMQ image, etc. so it will pull or download those base images from the Internet, from the public repo at the Docker registry named DOCKER HUB, by pulling the "microsoft/mssql-server-linux" which is the base image for the SQL Server for Linux on containers, and the "library/redis" which is the base Redis image, and so on. Therefore, the first time you run "docker-compose up" it might take a few minutes pulling those images before it spins up your custom containers.
|
||||||
|
|
||||||
|
Finally, you can see how the scripts waits after deploying all the containers:
|
||||||
|
|
||||||
|
<img src="img/cli-windows/docker-compose-up-1.2.png">
|
||||||
|
|
||||||
|
- The next time you run "docker-compose up" again, because you already have all the base images downloaded and registered in your local repo and your custom images built and ready to go, it'll be much faster since it just needs to deploy the containers, like the following screenshot:
|
||||||
|
|
||||||
|
<img src="img/cli-windows/docker-compose-up-2.png">
|
||||||
|
|
||||||
|
- <b>Check out the containers running in your Docker host</b>: Once docker-compose up finishes, you will have the original PowerShell window busy and showing the execution's output in a "wait state", so in order to ask to Docker about "how it went" and see what containers are running, you need to open a second PowerShell window and type "docker ps" so you'll see all the running containers, as shown in the following screenshot.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## B.1 - Building the application from a Docker Linux "build container"
|
## B.1 - Building the application from a Docker Linux "build container"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user