Browse Source

Add docker-compose file and README for Swarm

pull/810/head
Charles Lowell 7 years ago
parent
commit
ba2b247356
5 changed files with 242 additions and 4 deletions
  1. +32
    -4
      README.md
  2. +29
    -0
      README.swarm.md
  3. +99
    -0
      docker-compose.swarm.yml
  4. +2
    -0
      swarm/Dockerfile
  5. +80
    -0
      swarm/nginx.conf

+ 32
- 4
README.md View File

@ -77,23 +77,51 @@ This is the more straightforward way to get started:
https://github.com/dotnet/eShopOnContainers/wiki/02.-Setting-eShopOnContainer-solution-up-in-a-Visual-Studio-2017-environment
### CLI and Windows based
For those who prefer the CLI on Windows, using dotnet CLI, docker CLI and VS Code for Windows:
For those who prefer the CLI on Windows, using dotnet CLI, docker CLI and VS Code for Windows:
https://github.com/dotnet/eShopOnContainers/wiki/03.-Setting-the-eShopOnContainers-solution-up-in-a-Windows-CLI-environment-(dotnet-CLI,-Docker-CLI-and-VS-Code)
### CLI and Mac based
For those who prefer the CLI on a Mac, using dotnet CLI, docker CLI and VS Code for Mac
For those who prefer the CLI on a Mac, using dotnet CLI, docker CLI and VS Code for Mac
(Instructions still TBD, but similar to Windows CLI):
https://github.com/dotnet/eShopOnContainers/wiki/04.-Setting-eShopOnContainer-solution-up-in-a-Mac,-VS-Code-and-CLI-environment--(dotnet-CLI,-Docker-CLI-and-VS-Code)
> ### Note on tested Docker Containers/Images
> Most of the development and testing of this project was (as of early March 2017) done <b> on Docker Linux containers</b> running in development machines with "Docker for Windows" and the default Hyper-V Linux VM (MobiLinuxVM) installed by "Docker for Windows".
> Most of the development and testing of this project was (as of early March 2017) done <b> on Docker Linux containers</b> running in development machines with "Docker for Windows" and the default Hyper-V Linux VM (MobiLinuxVM) installed by "Docker for Windows".
The <b>Windows Containers scenario is currently being implemented/tested yet</b>. The application should be able to run on Windows Nano Containers based on different Docker base images, as well, as the .NET Core services have also been tested running on plain Windows (with no Docker).
The app was also partially tested on "Docker for Mac" using a development MacOS machine with .NET Core and VS Code installed, which is still a scenario using Linux containers running on the VM setup in the Mac by the "Docker for Windows" setup. But further testing and feedback on Mac environments and Windows Containers, from the community, will be appreciated.
## Docker Swarm
### Prerequisites
1. A Docker Swarm cluster ([Azure Container Service](https://docs.microsoft.com/en-us/azure/container-service/container-service-deployment))
1. Docker tooling, including docker-compose, on your development machine ([docker.com](https://www.docker.com/))
### Deploying to a Swarm Cluster
1. Open a command line to your local eShopOnContainers repository.
2. Restore and publish the projects:
>```
>dotnet restore eShopOnContainers-ServicesAndWebApps.sln
>dotnet publish eShopOnContainers-ServicesAndWebApps.sln -c Release -o ./obj/Docker/publish
>```
3. Create an SSH tunnel to your cluster's master node (See [Connect with an ACS cluster](https://docs.microsoft.com/en-us/azure/container-service/container-service-connect#connect-to-a-dcos-or-swarm-cluster))
4. Set `SWARM_AGENTS_FQDN` to the domain name of your swarm agents' load balancer. This is of the form `[dns prefix]agents.[azure region].cloudapp.azure.com` (it can also be found in the Azure portal). For example:
>```bash
>export SWARM_AGENTS_FQDN=myswarmclusteragents.centralus.cloudapp.azure.com
>```
Or, in PowerShell:
>```powershell
>$env:SWARM_AGENTS_FQDN='myswarmclusteragents.centralus.cloudapp.azure.com'
>```
5. Deploy eShopOnContainers with `docker-compose`:
>```
>docker-compose -f docker-compose.yml -f docker-compose.swarm.yml up -d
>```
### Further Reading
* Docker: [Swarm mode overview](https://docs.docker.com/engine/swarm/)
## Sending feedback and pull requests
As mentioned, we'd appreciate to your feedback, improvements and ideas.
You can create new issues at the issues section, do pull requests and/or send emails to **eshop_feedback@service.microsoft.com**
## Questions
[QUESTION] Answer +1 if the solution is working for you (Through VS2017 or CLI environment):
https://github.com/dotnet/eShopOnContainers/issues/107
https://github.com/dotnet/eShopOnContainers/issues/107

+ 29
- 0
README.swarm.md View File

@ -0,0 +1,29 @@
# eShopOnContainers on Docker Swarm
## Prerequisites
1. A Docker Swarm cluster ([Azure Container Service](https://docs.microsoft.com/en-us/azure/container-service/container-service-deployment))
1. Docker tooling, including docker-compose, on your development machine ([docker.com](https://www.docker.com/))
## Deploying to a Swarm Cluster
1. Open a command line to your local eShopOnContainers repository.
2. Restore and publish the projects:
>```
>dotnet restore eShopOnContainers-ServicesAndWebApps.sln
>dotnet publish eShopOnContainers-ServicesAndWebApps.sln -c Release -o ./obj/Docker/publish
>```
3. Create an SSH tunnel to your cluster's master node (See [Connect with an ACS cluster](https://docs.microsoft.com/en-us/azure/container-service/container-service-connect#connect-to-a-dcos-or-swarm-cluster))
4. Set `SWARM_AGENTS_FQDN` to the domain name of your swarm agents' load balancer. This is of the form `[dns prefix]agents.[azure region].cloudapp.azure.com` (it can also be found in the Azure portal). For example:
>```bash
>export SWARM_AGENTS_FQDN=myswarmclusteragents.centralus.cloudapp.azure.com
>```
Or, in PowerShell:
>```powershell
>$env:SWARM_AGENTS_FQDN='myswarmclusteragents.centralus.cloudapp.azure.com'
>```
5. Deploy eShopOnContainers with `docker-compose`:
>```
>docker-compose -f docker-compose.yml -f docker-compose.swarm.yml up -d
>```
## Further Reading
* Docker: [Swarm mode overview](https://docs.docker.com/engine/swarm/)

+ 99
- 0
docker-compose.swarm.yml View File

@ -0,0 +1,99 @@
version: '2'
services:
basket.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80/basket-api
- ConnectionString=basket.data
- IdentityUrl=http://${SWARM_AGENTS_FQDN}/identity
- EventBusConnection=rabbitmq
ports:
- "5100:80"
catalog.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80/catalog-api
- ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word
- ExternalCatalogBaseUrl=http://${SWARM_AGENTS_FQDN}/catalog-api
- EventBusConnection=rabbitmq
ports:
- "5101:80"
frontend:
build:
context: ./swarm
depends_on:
- basket.api
- catalog.api
- identity.api
- ordering.api
- webmvc
- webspa
- webstatus
ports:
- "80:8080"
identity.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80/identity
- SpaClient=http://${SWARM_AGENTS_FQDN}
- ConnectionStrings__DefaultConnection=Server=sql.data;Database=Microsoft.eShopOnContainers.Service.IdentityDb;User Id=sa;Password=Pass@word
- MvcClient=http://${SWARM_AGENTS_FQDN}/webmvc
ports:
- "5102:80"
ordering.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80/ordering-api
- ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word
- IdentityUrl=http://${SWARM_AGENTS_FQDN}/identity
- BasketUrl=http://${SWARM_AGENTS_FQDN}/basket-api
- EventBusConnection=rabbitmq
ports:
- "5103:80"
webmvc:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80/webmvc
- CatalogUrl=http://${SWARM_AGENTS_FQDN}/catalog-api
- OrderingUrl=http://${SWARM_AGENTS_FQDN}/ordering-api
- BasketUrl=http://${SWARM_AGENTS_FQDN}/basket-api
- IdentityUrl=http://${SWARM_AGENTS_FQDN}/identity
ports:
- "5104:80"
webspa:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80
- CatalogUrl=http://${SWARM_AGENTS_FQDN}/catalog-api
- OrderingUrl=http://${SWARM_AGENTS_FQDN}/ordering-api
- IdentityUrl=http://${SWARM_AGENTS_FQDN}/identity
- BasketUrl=http://${SWARM_AGENTS_FQDN}/basket-api
ports:
- "5105:80"
sql.data:
environment:
- SA_PASSWORD=Pass@word
- ACCEPT_EULA=Y
ports:
- "1433:1433"
webstatus:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80/webstatus
- CatalogUrl=http://${SWARM_AGENTS_FQDN}/catalog-api
- OrderingUrl=http://${SWARM_AGENTS_FQDN}/ordering-api
- BasketUrl=http://${SWARM_AGENTS_FQDN}/basket-api
- IdentityUrl=http://${SWARM_AGENTS_FQDN}/identity
- mvc=http://${SWARM_AGENTS_FQDN}/webmvc
- spa=http://${SWARM_AGENTS_FQDN}
ports:
- "5106:80"

+ 2
- 0
swarm/Dockerfile View File

@ -0,0 +1,2 @@
FROM nginx:1.10.3-alpine
COPY nginx.conf /etc/nginx/nginx.conf

+ 80
- 0
swarm/nginx.conf View File

@ -0,0 +1,80 @@
pid /tmp/nginx.pid;
worker_processes 1;
events {
worker_connections 1024;
}
http {
server_tokens off;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
client_body_temp_path /tmp/client_body;
fastcgi_temp_path /tmp/fastcgi_temp;
proxy_temp_path /tmp/proxy_temp;
scgi_temp_path /tmp/scgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
gzip on;
gzip_comp_level 6;
gzip_min_length 1024;
gzip_buffers 4 32k;
gzip_types text/plain application/javascript text/css;
gzip_vary on;
keepalive_timeout 65;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
server {
listen 8080;
location /basket-api {
proxy_pass http://basket.api;
proxy_redirect off;
proxy_set_header Host $host;
}
location /catalog-api {
proxy_pass http://catalog.api;
proxy_redirect off;
proxy_set_header Host $host;
}
location /identity {
proxy_pass http://identity.api;
proxy_redirect off;
proxy_set_header Host $host;
}
location /ordering-api {
proxy_pass http://ordering.api;
proxy_redirect off;
proxy_set_header Host $host;
}
location /webmvc {
proxy_pass http://webmvc;
proxy_redirect off;
proxy_set_header Host $host;
}
location /webstatus {
proxy_pass http://webstatus;
proxy_redirect off;
proxy_set_header Host $host;
}
location / {
proxy_pass http://webspa;
proxy_redirect off;
proxy_set_header Host $host;
}
}
}

Loading…
Cancel
Save