Skip to content
This repository was archived by the owner on Nov 10, 2019. It is now read-only.

Latest commit

 

History

History
105 lines (61 loc) · 4.06 KB

exercise08.md

File metadata and controls

105 lines (61 loc) · 4.06 KB

Exercise 8

Learnings

  1. Basics about new project system in ASP.NET Core 1.0
  2. Running web app with cross-platform web server Kestrel
  3. Basics about Node.js-based web tools in Visual Studio 2015
  4. Running ASP.NET Core web apps in a Docker container
  5. Packaging ASP.NET Core web apps in Docker images using a Dockerfile

ASP.NET Core 1 Web App in Visual Studio 2015

  1. Open Sample/AspNetCore1.sln in Visual Studio 2015.

  2. Build the solution and make sure that there are no errors.

  3. In Visual Studio, look at project.json and make yourself familiar with the code.

  4. Discussion points:

    • New project structure (.xproj)
    • New configuration system (JSON instead of XML, options-pattern, etc.)
    • Dependency injection in ASP.NET Core 1.0
    • Integration of web development tools like NPM, Node.js, Gulp, etc. in Visual Studio
    • Code walk-through for Angular 2.0 code
  5. Use Visual Studio's Task Runner to run Gulp task default.
    Task Runner

Run ASP.NET Core 1 with Kestrel

  1. Open a developer command prompt and navigate to the directory Sample/AspNetCore1.

  2. Discussion points:

  3. Run dotnet --help to make sure ASP.NET Core 1.0 RC2 is installed on your computer.

  4. Run dotnet restore to restore necessary packages from NuGet.

  5. Run npm install to restore necessary NPM packages.

  6. Run dotnet run to start your web app using the cross-platform Kestrel web server.
    Run Kestrel

  7. Discussion points:

    • Relation of Kestrel and IIS on Windows
  8. Open http://localhost:5000/index.html to test your web app.

Run Web App in a Docker Container

  1. Discussion points:

    • Short introduction into Docker's basic concepts
    • Speak about differences to virtual machines
    • Point out that this exercise uses the Docker host created in the previous exercise
  2. Use an SSH Client (on Windows e.g. PuTTY) and connect to your the VM you created in exercise 7.
    VM DNS name

  3. Make sure that Docker is up and running using: docker info

  4. Clone the sample repository for this training: git clone https://github.com/rstropek/PracticalDevOpsTraining.git

  5. Get Microsoft's Docker image for ASP.NET Core: docker pull microsoft/dotnet:latest

  6. Start a new interactive Docker container: docker run -it -p 5000:5000 -v ~/PracticalDevOpsTraining/Sample/AspNetCore1:/src microsoft/dotnet:latest /bin/bash. This command might take some moments if you run it for the first time. Subsequent calls should be much faster.

  7. Discussion points:

    • Describe concept of volume mappings (-v) and port mappings (-p)
  8. Inside of the Docker container, navigate to the mounted src folder: cd src

  9. Restore NuGet packages: dotnet restore

  10. Run our sample in the Docker container: dotnet run

  11. In your browser, open http://yourvmname.cloudapp.net:5000/api/books.

  12. Once you are done, exit from your Docker container using exit.

  13. Look for the container using docker ps -a. It should not be stopped. Delete your container using docker rm.

Create Docker Image for Web App

  1. Exit from Docker container but stay on Docker VM.

  2. Navigate to PracticalDevOpsTraining/Sample: cd ~/PracticalDevOpsTraining/Sample

  3. Build image from Dockerfile: docker build -t myaspnet .

  4. Discussion points:

    • Speak about basic concepts of Dockerfiles
    • Code walk-through for Dockerfile
  5. Run container from image: docker run -d -p 5000:5000 myaspnet

  6. Use docker ps and docker logs to make sure your container is up and running.

  7. In your browser, open http://yourvmname.cloudapp.net:5000/api/books.