Merge branch 'master' of https://github.com/dotnet/eShopOnContainers
21
README.md
@ -32,7 +32,7 @@ The app was also partially tested on "Docker for Mac" using a development MacOS
|
||||
|
||||
|
||||
## Development Environment Setup
|
||||
### Requirements for Dec. 2016 version of eShopOnContainers
|
||||
### Requirements for January 2016 version of eShopOnContainers
|
||||
|
||||
WINDOWS DEV MACHINE
|
||||
- Visual Studio 2015 with latest Update
|
||||
@ -49,8 +49,8 @@ MAC DEV MACHINE
|
||||
### Installing and configuring Docker in your development machine
|
||||
|
||||
#### Set needed assigned Memory and CPU to Docker
|
||||
In this application (January 2017 version) we run 1 instance of SQL Server running as a container plus 6 ASP.NET Core apps/services and 1 Redis server all of them running as Docker containers. So, especially because of SQL Server requirements on memory, it is important to set Docker up properly with enough memory RAM and CPU assigned to it or you will get difficult errors when starting the containers with "docker-compose up".
|
||||
Once Docker for Windows/Mac is installed in your machine, enter into its Settings and the Advanced menu option so you are able to adjust it to the new values (Memory: Around 6GB and CPU:4) as shown in the image. Usually you might need a 16GB or 12GB memory machine for this configuration. If you have a less powerful machine, you can try with a lower configuration and/or by not starting certain containers like the basket and Redis. But if you don't start all the containers, the application will not fully function properly, of course.
|
||||
In this application (January 2017 version) we run 1 instance of SQL Server running as a container with multiple databases (one DB per microservice), plus 6 ASP.NET Core apps/services and 1 Redis server, all of them running as Docker containers. So, especially because of SQL Server requirements on memory, it is important to set Docker up properly with enough memory RAM and CPU assigned to it or you will get difficult errors when starting the containers with "docker-compose up".
|
||||
Once Docker for Windows/Mac is installed in your machine, enter into its Settings and the Advanced menu option so you are able to adjust it to the minimum amount of memory and CPU (Memory: Around 4096MB and CPU:3) as shown in the image. Usually you might need a 16GB memory machine for this configuration if you also want to run the Android emulator for the Xamarin app at the same time. If you have a less powerful machine, you can try with a lower configuration and/or by not starting certain containers like the basket and Redis. But if you don't start all the containers, the application will not fully function properly, of course.
|
||||
|
||||
<img src="img/docker_settings.png">
|
||||
|
||||
@ -88,22 +88,23 @@ You can deploy Docker containers to a regularDocker host either by using the `do
|
||||
The next time you run docker-compose up, since it'll have those base images already pulled/downloaded, it will just start the containers, like in the following screenshot:
|
||||
<img src="img/docker-compose-up-2.png">
|
||||
|
||||
- <b>Check out the containers running in your Docker host</b>:Once docker-compose up finishes after a few minutes, you will have that PowerShell 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>Check out the containers running in your Docker host</b>: Once docker-compose up finishes after a few minutes, you will have that PowerShell 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.
|
||||
<img src="img/docker-ps-with-all-microservices.png">
|
||||
You can see the 6 custom containers running the microservices plus the 2 web applications. In adition you have the containers with the SQL databases and the Redis cache for the basket microservice data.
|
||||
|
||||
### Test the application and the microservices
|
||||
|
||||
#### IMPORTANT: Modify your local "hosts" file by setting an IP related to the identity.service network name
|
||||
- Due to the fact that when trying to authenticate against the STS (Security Token Service) container the browser is redirected to it from outside the docker host (your browser in your PC), it needs to have an IP reachable from outside the Docker Host. Therefore you need to add an entry like `10.0.75.1 identity.service` or `127.0.0.1 identity.service` to your <b>hosts</b> file in your local dev machine.
|
||||
- If you don't want to hassle with it, just run the PowerShell script named `add-host-entry.ps1` from the solution root folder.
|
||||
- If the STS were running in an external IP in a server, in the Internet or in any cloud like Azure, since that IP is reachable from anywhere, you wouldn't need to configure your hosts file. However, that IP would need to be updated into your docker-compose.yml file, in the identity.service URLs.
|
||||
#### Test the applications and microservices
|
||||
|
||||
### Test the applications and microservices
|
||||
Once the deploy process of docker-compose finishes you should be able to access the services in the following URLs or connection string, from your dev machine:
|
||||
- Web MVC: http://localhost:5100
|
||||
- Web Spa: http://localhost:5104
|
||||
- Catalog microservice: http://localhost:5101
|
||||
- Ordering microservice: http://localhost:5102
|
||||
- Basket microservice: http://localhost:5103
|
||||
- Web Spa: http://localhost:5104 (Important, check how to set up the SPA app and requirements before building the Docker images. Instructions at https://github.com/dotnet/eShopOnContainers/tree/master/src/Web/WebSPA/eShopOnContainers.WebSPA or the README.MD from eShopOnContainers/src/Web/WebSPA/eShopOnContainers.WebSPA)
|
||||
- Catalog microservice: http://localhost:5101 (Not secured)
|
||||
- Ordering microservice: http://localhost:5102 (Requires token for authorization)
|
||||
- Basket microservice: http://localhost:5103 (Requires token for authorization)
|
||||
- Identity microservice: http://localhost:5105
|
||||
- Orders database (SQL Server): Server=tcp:localhost,5432;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;
|
||||
- Catalog database (SQL Server): Server=tcp:localhost,5434;Database=CatalogDB;User Id=sa;Password=Pass@word
|
||||
|
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 120 KiB |
Before Width: | Height: | Size: 3.1 MiB After Width: | Height: | Size: 3.0 MiB |
BIN
img/spa/installing_npm_node.png
Normal file
After Width: | Height: | Size: 175 KiB |
BIN
img/spa/npm-rebuild-node-sass.png
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
img/spa/npm-run-build.png
Normal file
After Width: | Height: | Size: 177 KiB |
BIN
img/spa/npm-versions-powershell.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
img/spa/vs-tools-path-custom-node.png
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
img/spa/vs-tools-path-original.png
Normal file
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 45 KiB |
@ -25,7 +25,7 @@ namespace eShopOnContainers
|
||||
|
||||
private void InitApp()
|
||||
{
|
||||
UseMockServices = true;
|
||||
UseMockServices = false;
|
||||
|
||||
ViewModelLocator.Instance.UpdateDependencies(UseMockServices);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
public GlobalSetting()
|
||||
{
|
||||
AuthToken = "INSERT AUTHENTICATION TOKEN";
|
||||
BaseEndpoint = "http://13.88.8.119";
|
||||
BaseEndpoint = "http://10.106.144.28";
|
||||
}
|
||||
|
||||
public static GlobalSetting Instance
|
||||
|
@ -1,31 +1,48 @@
|
||||
# Containerized eShop - Web Spa
|
||||
Sample reference containerized application, cross-platform and microservices architecture.
|
||||
Powered by Microsoft
|
||||
|
||||
#Overview
|
||||
This sample runs a microservices oriented application and a .net core Mvc application that consumes this services. You can find more information about how to set up docker in your machine in the global directory solution.
|
||||
|
||||
#Deploy
|
||||
In the global directory you will find the scripts needed to run and deploy the demo into your local docker infraestructure.
|
||||
|
||||
- <a href='build-image-web-spa.ps1'>build-image-web-spa.ps1</a> <b>Build .net applications and docker images</b>: This power shell script that you will find in the <u>root directory of the solution</u> is the responsible of building .net applications and package in a pub folder and use docker commands to build the images needed to run the previously packaged .net applications.
|
||||
|
||||
- <b>Compose containers in your docker local VM</b>: Finally you have to open your favourite command tool pointing to the <u>root directory of this project</u> where docker-compose.yml file is located and run the command `docker-compose up`
|
||||
|
||||
#Run
|
||||
Once the deploy process of docker-compose finishes you have to be able to access the services in this urls:
|
||||
- Web: http://localhost:5104
|
||||
- Catalog service: http://localhost:5101
|
||||
- Orders service: http://localhost:5102
|
||||
- Basket service: http://localhost:5103
|
||||
- Identity service: http://localhost:5105
|
||||
- Orders data (SQL Server): Server=tcp:localhost,5432;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;
|
||||
- Catalog data (SQL Server): Server=tcp:localhost,5434;Database=CatalogDB;User Id=sa;Password=Pass@word
|
||||
- Identity data (SQL Server): Server=localhost,5433;Database=aspnet-Microsoft.eShopOnContainers;User Id=sa;Password=Pass@word
|
||||
- Basket data (Redis): listening in localhost:6379
|
||||
# eShop Web SPA (Single Page Application)
|
||||
|
||||
|
||||
## Requirements and set up
|
||||
|
||||
|
||||
### Install NPM
|
||||
The SPA application is using a newer version of NPM than the one provided by Visual Studio 2015 (npm 2.7.4 currently), so you need to install the latest stable version of NPM.
|
||||
|
||||
NPM is bundled with NODE.JS. Installing NPM and NODE is pretty straightforward by using the installer package available at https://nodejs.org/en/
|
||||
|
||||
<img src="../../../../img/spa/installing_npm_node.png">
|
||||
You can install the version "Recommended For Most Users" of Node which at the moment of this writing was v6.9.3 LTS and comes with a newer version of NPM.
|
||||
You can see your initial NPM version and the installed NPM version with the command
|
||||
<b>npm -v</b>, as shown below.
|
||||
<p>
|
||||
<img src="../../../../img/spa/npm-versions-powershell.png">
|
||||
|
||||
### Set NPM path into Visual Studio
|
||||
NPM will be usually installed under this path:
|
||||
<b>C:\Program Files (x86)\nodejs</b>.
|
||||
You need to update that path in Visual Studio 2015 under the "External Web Tools" location paths, as shown below:
|
||||
<p>
|
||||
<img src="../../../../img/spa/vs-tools-path-custom-node.png">
|
||||
|
||||
### Build the SPA app with NPM
|
||||
Finally, you need to build the SPA app (TypeScript and Angular based client app) with NPM.
|
||||
* Open a command-prompt window and move to the root of the SPA application (src\Web\WebSPA\eShopOnContainers.WebSPA)
|
||||
* Run the command <b>npm run build:prod</b> as shown below:
|
||||
<p>
|
||||
<img src="../../../../img/spa/npm-run-build.png">
|
||||
|
||||
If you get an error like <b>"Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 6.x"</b>, then run the command <b>npm rebuild node-sass</b> as in the following screenshot:
|
||||
<img src="../../../../img/spa/npm-rebuild-node-sass.png">
|
||||
Then, run again the <b>npm run build:prod</b> command that should finish with no errors.
|
||||
|
||||
### Build/create the Docker images
|
||||
Create the Docker images with the <b>build-images.ps1</b> PowerShell script in Windows (or the <b>build-images.sh</b> bash script in a Mac) as explained in the main instructions at https://github.com/dotnet/eShopOnContainers/
|
||||
|
||||
### Deploy/run the Docker containers
|
||||
Deploy/run the Docker containers with <b>"docker-compose up"</b> as explained in the main instructions at https://github.com/dotnet/eShopOnContainers/
|
||||
|
||||
### Test the SPA web application
|
||||
|
||||
Test the SPA app by running the following URL in a browser:
|
||||
<b> http://TBD</b>
|
||||
|
||||
|
||||
|