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
99a4a12421
commit
efdd7bcfeb
@ -20,83 +20,7 @@ If your projects are placed within the /Users folder, you don't need to configur
|
||||
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
|
||||
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.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. [Docker for Mac](https://docs.docker.com/docker-for-mac/install/). (You should already have this installed)
|
||||
1. [Visual Studio for Mac](https://www.visualstudio.com/vs/visual-studio-mac/).
|
||||
|
||||
## Install Visual Studio for Mac
|
||||
|
||||
When installing [Docker for Mac](https://docs.docker.com/docker-for-mac/install/), you can select between multiple workloads or platforms.
|
||||
|
||||
Make sure you select the .NET Core platform:
|
||||
|
||||

|
||||
|
||||
Before completing the VS for Mac installation, it will demand you to install XCode, that is needed for multiple dependencies.
|
||||
|
||||
If you install Android as a target platform, Java will also be installed as a dependency for building mobile apps for Android.
|
||||
|
||||
For running just the Docker containers and web apps, you'd just need the .NET Core platform.
|
||||
|
||||
But if you want to try the eShopOnContainers mobile app, that requires Xamarin and therefore, the iOS and Android platforms, too. Those mobile platforms are optional for this Wiki walkthrough, though.
|
||||
|
||||
## Clone the eShopOnContainers repo
|
||||
|
||||
Open a bash shell and run the following command:
|
||||
|
||||
```
|
||||
$ mkdir MyGitRepos
|
||||
$ cd MyGitRepos
|
||||
$ git clone https://github.com/dotnet-architecture/eShopOnContainers.git
|
||||
$ cd eShopOnContainers
|
||||
```
|
||||
|
||||
With that, you'll have the code at /Users/yourUser/MyGitRepos/eShopOnContainers folder.
|
||||
|
||||
## Open the 'eShopOnContainers-ServicesAndWebApps.sln' solution with VS for Mac
|
||||
|
||||
Run Visual Studio for Mac and open the solution `eShopOnContainers-ServicesAndWebApps.sln`.
|
||||
|
||||
If you just want to run the containers/microservices and web apps, do NOT open the other solutions, like `eShopOnContainers.sln` as those solutions will also open the Xamarin projects and that might slow you down when testing due to additional dependencies in VS.
|
||||
|
||||
After opening the `eShopOnContainers-ServicesAndWebApps.sln` solution for the first time, it is recommended to wait for a few minutes as VS will be restoring many NuGet packages and the solution won't be able to compile or run until it gets all the nuGet packages dependencies, in the first place (this time is only needed the first time you open the solution. Next times it is a lot faster).
|
||||
|
||||
This is VS for Mac with the `eShopOnContainers-ServicesAndWebApps.sln` solution.
|
||||
|
||||

|
||||
|
||||
## Run eShopOnContainers from VS for Mac (F5 or Ctrl+F5)
|
||||
|
||||
Make sure that the by default start-up project is the Docker project named `docker-compose`.
|
||||
|
||||
Hit Ctrl+F5 or press the "play" button in VS for Mac.
|
||||
|
||||
IMPORTANT: The first time you run eShopOnContainers, it will take longer than the next time you launch it. Under the covers, Docker is pulling quite a few "heavy" images from Docker Hub (the public image registry), like the SQL Server image, Redis image, RabbitMQ image and the base ASP.NET Core images. That pull/download process will take a few minutes. Then, VS will launch the application custom containers plus the infrastructure containers (SQL, Redis, RabbitMQ and MongoDB), populate sample data in the databases and finally run the microservices and web apps on custom containers.
|
||||
|
||||
Note that you will see normal/controlled Http exceptions caused by our retries with exponential backoff, as the web apps have to wait until the microservices are ready for the first time which need first to run SQL sentences populating sample data, etc.
|
||||
|
||||
Once the solution is up and running, you should be able to see it in the browser at:
|
||||
|
||||
http://localhost:5100
|
||||
|
||||

|
||||
|
||||
If you open a bash window, you can type `docker images` and see the pulled/downloaded images plus the custom images created by VS for Mac:
|
||||
|
||||

|
||||
|
||||
And by typing `docker ps` you can see the containers running in Docker. The infrastructure containers like SQL, Redis, RabbitMQ plus the custom containers running Web API microservices and the web apps.
|
||||
|
||||

|
||||
|
||||
*IMPORTANT:* In order to have the full app working, like being able to login with a user and add items to the basket and create orders, or being able to consume the services from a remote Xamarin or web SPA, you need to configure additional steps for the app, like the IP to be used by the Identity Service because it needs to be redirected, etc. - Check the additional configuration at the end of this post.
|
||||
|
||||
|
||||
# Option B: Use a CLI environment (dotnet CLI, Docker CLI with the bash shell) and VS Code as plain editor
|
||||
# Option A: Use a CLI environment (dotnet CLI, Docker CLI with the bash shell) and VS Code as plain editor
|
||||
|
||||
As a summary, with the following simple CLI commands in a bash window you'll be able to build the Docker images and deploy the containers into your local Docker host:
|
||||
|
||||
@ -176,8 +100,88 @@ Type `docker ps`
|
||||
|
||||

|
||||
|
||||
## How to run/test the application
|
||||
Basically, at this point you can test the app with a browser at `http://localhost:5100`.
|
||||
|
||||
## Running/testing the application
|
||||
For further apps and tests, check the last section of this post named "Running/testing the application" so you see how to run the multiple apps and services in the browser.
|
||||
|
||||
# Option B: 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.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. [Docker for Mac](https://docs.docker.com/docker-for-mac/install/). (You should already have this installed)
|
||||
1. [Visual Studio for Mac](https://www.visualstudio.com/vs/visual-studio-mac/).
|
||||
|
||||
## Install Visual Studio for Mac
|
||||
|
||||
When installing [Docker for Mac](https://docs.docker.com/docker-for-mac/install/), you can select between multiple workloads or platforms.
|
||||
|
||||
Make sure you select the .NET Core platform:
|
||||
|
||||

|
||||
|
||||
Before completing the VS for Mac installation, it will demand you to install XCode, that is needed for multiple dependencies.
|
||||
|
||||
If you install Android as a target platform, Java will also be installed as a dependency for building mobile apps for Android.
|
||||
|
||||
For running just the Docker containers and web apps, you'd just need the .NET Core platform.
|
||||
|
||||
But if you want to try the eShopOnContainers mobile app, that requires Xamarin and therefore, the iOS and Android platforms, too. Those mobile platforms are optional for this Wiki walkthrough, though.
|
||||
|
||||
## Clone the eShopOnContainers repo
|
||||
|
||||
Open a bash shell and run the following command:
|
||||
|
||||
```
|
||||
$ mkdir MyGitRepos
|
||||
$ cd MyGitRepos
|
||||
$ git clone https://github.com/dotnet-architecture/eShopOnContainers.git
|
||||
$ cd eShopOnContainers
|
||||
```
|
||||
|
||||
With that, you'll have the code at /Users/yourUser/MyGitRepos/eShopOnContainers folder.
|
||||
|
||||
## Open the 'eShopOnContainers-ServicesAndWebApps.sln' solution with VS for Mac
|
||||
|
||||
Run Visual Studio for Mac and open the solution `eShopOnContainers-ServicesAndWebApps.sln`.
|
||||
|
||||
If you just want to run the containers/microservices and web apps, do NOT open the other solutions, like `eShopOnContainers.sln` as those solutions will also open the Xamarin projects and that might slow you down when testing due to additional dependencies in VS.
|
||||
|
||||
After opening the `eShopOnContainers-ServicesAndWebApps.sln` solution for the first time, it is recommended to wait for a few minutes as VS will be restoring many NuGet packages and the solution won't be able to compile or run until it gets all the nuGet packages dependencies, in the first place (this time is only needed the first time you open the solution. Next times it is a lot faster).
|
||||
|
||||
This is VS for Mac with the `eShopOnContainers-ServicesAndWebApps.sln` solution.
|
||||
|
||||

|
||||
|
||||
## Run eShopOnContainers from VS for Mac (F5 or Ctrl+F5)
|
||||
|
||||
Make sure that the by default start-up project is the Docker project named `docker-compose`.
|
||||
|
||||
Hit Ctrl+F5 or press the "play" button in VS for Mac.
|
||||
|
||||
IMPORTANT: The first time you run eShopOnContainers, it will take longer than the next time you launch it. Under the covers, Docker is pulling quite a few "heavy" images from Docker Hub (the public image registry), like the SQL Server image, Redis image, RabbitMQ image and the base ASP.NET Core images. That pull/download process will take a few minutes. Then, VS will launch the application custom containers plus the infrastructure containers (SQL, Redis, RabbitMQ and MongoDB), populate sample data in the databases and finally run the microservices and web apps on custom containers.
|
||||
|
||||
Note that you will see normal/controlled Http exceptions caused by our retries with exponential backoff, as the web apps have to wait until the microservices are ready for the first time which need first to run SQL sentences populating sample data, etc.
|
||||
|
||||
Once the solution is up and running, you should be able to see it in the browser at:
|
||||
|
||||
http://localhost:5100
|
||||
|
||||

|
||||
|
||||
If you open a bash window, you can type `docker images` and see the pulled/downloaded images plus the custom images created by VS for Mac:
|
||||
|
||||

|
||||
|
||||
And by typing `docker ps` you can see the containers running in Docker. The infrastructure containers like SQL, Redis, RabbitMQ plus the custom containers running Web API microservices and the web apps.
|
||||
|
||||

|
||||
|
||||
*IMPORTANT:* In order to have the full app working, like being able to login with a user and add items to the basket and create orders, or being able to consume the services from a remote Xamarin or web SPA, you need to configure additional steps for the app, like the IP to be used by the Identity Service because it needs to be redirected, etc. - Check the additional configuration at the end of this post.
|
||||
|
||||
|
||||
# Running/testing the application
|
||||
|
||||
Once the containers have launched, open a browser and navigate to `http://localhost:5100` to visit the MVC application:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user