14. Docker File
• Text file used to build Docker images
• Contains build instructions
• Instructions create intermediate image that can be cached to speed
up future builds
FROM ENTRYPOINT ENV
RUN WORKDIR VOLUME
COPY EXPOSE CMD
15. Container Network
• Networking with containers is a very important feature
• Allows users to define their own networks and connect containers to
them
• Create a network on a single host or a network that spans across
multiple hosts
docker network create [OPTIONS] my-network
docker run –d --net=my-network --name my-container mongo
docker network ls
docker network inspect my-network
16. Docker Compose
• Manage the whole application lifecycle
• Build service configuration file (docker-compose.yml)
17. Docker Swarm
• Container orchestration platform
• Developed by Docker
• Open-source
• 3500+ commits, 150+ contributors
• Tightly integrated into the Docker ecosystem
• Use Docker API and networking
• Zero single-point-of-failure architecture
• Simple installation
• Easier learning curve
18. Kubernete
• Container orchestration platform
• Built by Google
• Open-source
• 65000+ commits, 1500+ contributors
• More mature
• Largest market share
• More extensive and customizable
• Manual installation
• Serious planning to make up and down
• Steep learning curve
19. Asp.Net Core
• Open Source
• Improved Performance
• Host on IIS, Nginx, Apache or self-host
• Ability to build and run on Windows, macOS, and Linux
• Built-in dependency injection
• Light-weight and modular HTTP request pipeline
• Environment-based configuration
• Simplified csproj file
• Ships entirely as NuGet packages
• View Component, Tag Helpers
25. Middleware
• Asp.net Core Apps are built on the middleware pipeline
• Opposed to HttpHandlers and HttpModules, middleware is created
and used programmatically without a config file
• Add and Remove easily in the Configure method of the Startup
26. Middleware
Some of the built-in middlewares :
• Authentication
• CORS
• Response caching
• Response compression
• Routing
• Session
• Static files
• URL rewriting
28. Razor Pages
• @page
• MVVM Framework
• Two-way Data Binding
• Razor support
• Tag Helpers
• HTML Helpers
• Handlers (OnGet, OnGetAsync, OnPostAsync etc..)
29. View Component
• Create more Reusable Components than Partial Views
• More Powerful
• Have parameters and business logic
• Loaded from External Assemblies
• Used whenever need templates for views, for rendering a group of
elements, and associating server code with it
30. Tag Helpers
• Allow server-side code to be used when creating and rendering HTML
elements
• ASP.NET Core 2.0 already provides many built-in Tag Helpers
• Used whenever append behavior to a single HTML element
Docker is available for implementation across a wide range of platforms:
Desktop: Mac OS, Windows 10.
Server: Various Linux distributions and Windows Server 2016.
Cloud: Amazon Web Services, Google Compute Platform, Microsoft Azure, IBM Cloud, and more.
Docker Daemon: A persistent background process that manages Docker images, containers, networks, and storage volumes. The Docker daemon constantly listens for Docker API requests and processes them.
Docker Engine REST API: An API used by applications to interact with the Docker daemon; it can be accessed by an HTTP client.
Docker CLI: A command line interface client for interacting with the Docker daemon. It greatly simplifies how you manage container instances and is one of the key reasons why developers love using Docker.
docker run -ti busybox (interactive)
kill all running containers with docker kill $(docker ps -q)
delete all stopped containers with docker rm $(docker ps -a -q)
delete all images with docker rmi $(docker images -q)
Running Container & Inspect
Volume: Special type of directory in a container typically referred to as a “data volume”
Can be shared and reused among containers
Updates to an image won’t affect a data volume
docker run –p 8080:3000 –v $(pwd):/app microsoft/aspnetcore-build
docker inspect containerId
FROM creates a layer from the ubuntu:15.04 Docker image.
COPY adds files from your Docker client’s current directory.
RUN builds your application with make.
CMD specifies what command to run within the container.
CMD [“/bin/bash”, “-c”, “dotnet restore && dotnet run”]
EXPOSE DockerHostPort
ENTRYPOINT dotnet myapp.dll
All Docker installations represent the docker0 network with bridge; Docker connects to bridge by default.
Run ifconfig on the Linux host to view the bridge network
Docker-compose.yml: Build, environment, image, networks, volumes, ports
docker-compose build
docker-compose up (create and start containers)
docker-compose down (stop and remove containers)
docker-compose logs
docker-compose ps
docker-compose start
docker-compose stop
docker-compose rm
using an internal cluster management system called Borg (sometimes referred to as Omega)
due to being out longer (v1.0 came out in July 2015)
The Program class is the main entry point for ASP.NET Core 2.0 applications. In fact, ASP.NET Core 2.0 applications are very similar to standard .NET Framework console applications in this regard
The new Microsoft.AspNet.Core.All package contains all ASP.NET Core 2.0 features in a single library.(you can still reference them manually instead of using the single packages) The runtime store is an important new component shipped with ASP.NET Core 2.0. It contains compiled packages, which were compiled using the native machine language and it is key for improved performance. All applications using the Microsoft.AspNet.Core.All package benefit from it
Docker container images including ASP.NET Core 2.0 applications are much smaller than images with classic ASP.NET applications, meaning that they are faster to deploy and to start-up.
Previous versions of ASP.NET had a very close relation with Internet Information Services (IIS),
Wanting to change this, Microsoft defined the Open Web Interface for .NET (OWIN) specification
.NET Core borrowed heavily from the OWIN specification. There are no more Global.asax, web.config, or machine.config configuration files, modules or handlers
Some bootstrap code declares a class that contains a convention-defined method (Startup will be used, if no class is declared)
This conventional method, which should be called Configure, receives as its sole parameter a pointer to an IApplicationBuilder instance
You then start adding middleware to the IApplicationBuilder; this middleware is what will handle your web requests
Microsoft estimates that about 70% of the libraries on NuGet should just work with .NET Core now
WCF, WPF API
Additional Topics
HostingEnvironment => launchSettings.json, Command-line arguments, encrypted user store, custom provider
ASPNETCORE_ENVIRONMENT => Development, Staging, Production
An HttpModule runs for each request before arriving at the handler that generates the response, and/or after it generates the response
A Handler handles the request and generates the response for a given file extension
_ViewImports.cshtml @using AspNetCoreDemo
@addTagHelper*, Microsoft.AspNetCore.Mvc.TagHelpers
_ViewStart.cshtml @{ Layout = "~/Views/Shared/_Layout.cshtml"; }
Access to these files is not available by default app.UseStaticFiles();
Note that by default all static files served by this middleware are public and anyone can access them. If you need to protect some of your files, you need to either store them outside the wwwroot folder or you need to use the FileResult controller action, which supports the authorization middleware.
Activate Session: app.UseSession();
Instance: The instance is given all the time. We are responsible for its creation.
Transient: The instance is created each time we use the object.
Scoped: The instance is created once by the HTTP request.
Singleton: The instance is created once by the application instance.
Kestrel is the default, multi-platform, web server. It offers acceptable performance, but lacks lots of features that are expected in real-life:
No buffering
No support for Windows authentication (as time passes, this is less of a problem)
No WebSockets
No HTTP/2
No direct file transmission
No strong security protection