Skip to content

Commit

Permalink
chore: Cleanup devlang for code blocks (#20609)
Browse files Browse the repository at this point in the history
* chore: Cleanup devlang for code blocks

Automated cleanup from docs authoring pack

* fix: "docker" devlang to "console"

* fix: "docker" devlang to "dockerfile
  • Loading branch information
nschonni authored Sep 14, 2020
1 parent d272247 commit 153df0e
Show file tree
Hide file tree
Showing 20 changed files with 68 additions and 68 deletions.
8 changes: 4 additions & 4 deletions docs/architecture/cloud-native/feature-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Feature flags also promote `trunk-based` development. It's a source-control bran

At its core, a feature flag is a reference to a simple `decision object`. It returns a Boolean state of `on` or `off`. The flag typically wraps a block of code that encapsulates a feature capability. The state of the flag determines whether that code block executes for a given user. Figure 10-11 shows the implementation.

```c#
```csharp
if (featureFlag) {
// Run this code block if the featureFlag value is true
} else {
Expand All @@ -44,15 +44,15 @@ Feature flags can be easily implemented in an [ASP.NET Core service](https://doc

Once configured in your Startup class, you can add feature flag functionality at the controller, action, or middleware level. Figure 10-12 presents controller and action implementation:

```c#
```csharp
[FeatureGate(MyFeatureFlags.FeatureA)]
public class ProductController : Controller
{
...
}
```

```c#
```csharp
[FeatureGate(MyFeatureFlags.FeatureA)]
public IActionResult UpdateProductStatus()
{
Expand All @@ -66,7 +66,7 @@ If a feature flag is disabled, the user will receive a 404 (Not Found) status co

Feature flags can also be injected directly into C# classes. Figure 10-13 shows feature flag injection:

```c#
```csharp
public class ProductController : Controller
{
private readonly IFeatureManager _featureManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Visual Studio supports Docker development for web-based applications. When you c

When this option is selected, the project is created with a `Dockerfile` in its root, which can be used to build and host the app in a Docker container. An example Dockerfile is shown in Figure 3-6.git

```docker
```dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Using an official repository of a language stack with a version number ensures t

The following is a sample DockerFile for a .NET Core container:

```Dockerfile
```dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ With [Windows Containers](/virtualization/windowscontainers/about/index), you ca

To use Windows Containers, you just need to write Windows PowerShell commands in the DockerFile, as demonstrated in the following example:

```Dockerfile
```dockerfile
FROM microsoft/windowsservercore
LABEL Description="IIS" Vendor="Microsoft" Version="10"
RUN powershell -Command Add-WindowsFeature Web-Server
Expand All @@ -20,7 +20,7 @@ In this case, we're using Windows PowerShell to install a Windows Server Core ba

In a similar way, you also could use Windows PowerShell commands to set up additional components like the traditional ASP.NET 4.x and .NET 4.6 or any other Windows software, as shown here:

```Dockerfile
```dockerfile
RUN powershell add-windowsfeature web-asp-net45
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Using an official .NET image repository from Docker Hub with a version number en

The following example shows a sample Dockerfile for an ASP.NET Core container.

```Dockerfile
```dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
ARG source
WORKDIR /app
Expand Down Expand Up @@ -167,7 +167,7 @@ Probably the best way to understand multi-stage is going through a Dockerfile in

The initial Dockerfile might look something like this:

```Dockerfile
```dockerfile
1 FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
2 WORKDIR /app
3 EXPOSE 80
Expand Down Expand Up @@ -238,7 +238,7 @@ You'll take advantage of Docker's layer cache feature, which is quite simple: if

So, let's focus on the **build** stage, lines 5-6 are mostly the same, but lines 7-17 are different for every service from eShopOnContainers, so they have to execute every single time, however if you changed lines 7-16 to:

```Dockerfile
```dockerfile
COPY . .
```

Expand All @@ -250,7 +250,7 @@ Then it would be just the same for every service, it would copy the whole soluti

The next significant optimization involves the `restore` command executed in line 17, which is also different for every service of eShopOnContainers. If you change that line to just:

```Dockerfile
```dockerfile
RUN dotnet restore
```

Expand All @@ -270,7 +270,7 @@ For the final optimization, it just happens that line 20 is redundant, as line 2

The resulting file is then:

```Dockerfile
```dockerfile
1 FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
2 WORKDIR /app
3 EXPOSE 80
Expand Down Expand Up @@ -553,7 +553,7 @@ In addition, you need to perform step 2 (adding Docker support to your projects)

[Windows Containers](https://docs.microsoft.com/virtualization/windowscontainers/about/index) allow you to convert your existing Windows applications into Docker images and deploy them with the same tools as the rest of the Docker ecosystem. To use Windows Containers, you run PowerShell commands in the Dockerfile, as shown in the following example:

```Dockerfile
```dockerfile
FROM mcr.microsoft.com/windows/servercore
LABEL Description="IIS" Vendor="Microsoft" Version="10"
RUN powershell -Command Add-WindowsFeature Web-Server
Expand All @@ -562,7 +562,7 @@ CMD [ "ping", "localhost", "-t" ]

In this case, we are using a Windows Server Core base image (the FROM setting) and installing IIS with a PowerShell command (the RUN setting). In a similar way, you could also use PowerShell commands to set up additional components like ASP.NET 4.x, .NET 4.6, or any other Windows software. For example, the following command in a Dockerfile sets up ASP.NET 4.5:

```Dockerfile
```dockerfile
RUN powershell add-windowsfeature web-asp-net45
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static int Main(string[] args)

There's an important caveat when applying migrations and seeding a database during container startup. Since the database server might not be available for whatever reason, you must handle retries while waiting for the server to be available. This retry logic is handled by the `MigrateDbContext()` extension method, as shown in the following code:

```cs
```csharp
public static IWebHost MigrateDbContext<TContext>(
this IWebHost host,
Action<TContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ The HTTP request will end up running that kind of C# code accessing the microser

Regarding the microservice URL, when the containers are deployed in your local development PC (local Docker host), each microservice's container always has an internal port (usually port 80) specified in its dockerfile, as in the following dockerfile:

```Dockerfile
```dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ The values set in the run-time environment always override the values defined in

If you are exploring Docker and .NET Core on sources on the Internet, you will find Dockerfiles that demonstrate the simplicity of building a Docker image by copying your source into a container. These examples suggest that by using a simple configuration, you can have a Docker image with the environment packaged with your application. The following example shows a simple Dockerfile in this vein.

```Dockerfile
```dockerfile
FROM mcr.microsoft.com/dotnet/core/sdk:3.1
WORKDIR /app
ENV ASPNETCORE_URLS http://+:80
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ networks:
The `docker-compose.yml` file references the `Dockerfile` in the `Web` project. The `Dockerfile` is used to specify which base container will be used and how the application will be configured on it. The `Web`' `Dockerfile`:

```Dockerfile
```dockerfile
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ namespace Microsoft.eShopWeb.FunctionalTests.Web

Tests can make use of this custom WebApplicationFactory by using it to create a client and then making requests to the application using this client instance. The application will have data seeded that can be used as part of the test's assertions. The following test verifies that the home page of the eShopOnWeb application loads correctly and includes a product listing that was added to the application as part of the seed data.

```cs
```csharp
using Microsoft.eShopWeb.FunctionalTests.Web;
using System.Net.Http;
using System.Threading.Tasks;
Expand Down
36 changes: 18 additions & 18 deletions docs/core/docker/build-container.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ docker-working

From your terminal, run the following command:

```Docker
```console
docker build -t counter-image -f Dockerfile .
```

Docker will process each line in the *Dockerfile*. The `.` in the `docker build` command tells Docker to use the current folder to find a *Dockerfile*. This command builds the image and creates a local repository named **counter-image** that points to that image. After this command finishes, run `docker images` to see a list of images installed:

```Docker
```console
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
counter-image latest e6780479db63 4 days ago 190MB
Expand All @@ -238,7 +238,7 @@ The next command, `ENTRYPOINT`, tells Docker to configure the container to run a

From your terminal, run `docker build -t counter-image -f Dockerfile .` and when that command finishes, run `docker images`.

```Docker
```console
docker build -t counter-image -f Dockerfile .
Sending build context to Docker daemon 1.117MB
Step 1/4 : FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
Expand Down Expand Up @@ -268,14 +268,14 @@ Each command in the *Dockerfile* generated a layer and created an **IMAGE ID**.

Now that you have an image that contains your app, you can create a container. You can create a container in two ways. First, create a new container that is stopped.

```Docker
```console
docker create --name core-counter counter-image
0f281cb3af994fba5d962cc7d482828484ea14ead6bfe386a35e5088c0058851
```

The `docker create` command from above will create a container based on the **counter-image** image. The output of that command shows you the **CONTAINER ID** (yours will be different) of the created container. To see a list of *all* containers, use the `docker ps -a` command:

```Docker
```console
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0f281cb3af99 counter-image "dotnet NetCore.Dock…" 40 seconds ago Created core-counter
Expand All @@ -285,7 +285,7 @@ CONTAINER ID IMAGE COMMAND CREATED STA

The container was created with a specific name `core-counter`, this name is used to manage the container. The following example uses the `docker start` command to start the container, and then uses the `docker ps` command to only show containers that are running:

```Docker
```console
docker start core-counter
core-counter

Expand All @@ -296,7 +296,7 @@ CONTAINER ID IMAGE COMMAND CREATED STAT

Similarly, the `docker stop` command will stop the container. The following example uses the `docker stop` command to stop the container, and then uses the `docker ps` command to show that no containers are running:

```Docker
```console
docker stop core-counter
core-counter

Expand All @@ -310,7 +310,7 @@ After a container is running, you can connect to it to see the output. Use the `

After you detach from the container, reattach to verify that it's still running and counting.

```Docker
```console
docker start core-counter
core-counter

Expand All @@ -331,13 +331,13 @@ Counter: 19

For the purposes of this article you don't want containers just hanging around doing nothing. Delete the container you previously created. If the container is running, stop it.

```Docker
```console
docker stop core-counter
```

The following example lists all containers. It then uses the `docker rm` command to delete the container, and then checks a second time for any running containers.

```Docker
```console
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2f6424a7ddce counter-image "dotnet NetCore.Dock…" 7 minutes ago Exited (143) 20 seconds ago core-counter
Expand All @@ -353,7 +353,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

Docker provides the `docker run` command to create and run the container as a single command. This command eliminates the need to run `docker create` and then `docker start`. You can also set this command to automatically delete the container when the container stops. For example, use `docker run -it --rm` to do two things, first, automatically use the current terminal to connect to the container, and then when the container finishes, remove it:

```Docker
```console
docker run -it --rm counter-image
Counter: 1
Counter: 2
Expand All @@ -365,7 +365,7 @@ Counter: 5

The container also passes parameters into the execution of the .NET Core app. To instruct the .NET Core app to count only to 3 pass in 3.

```Docker
```console
docker run -it --rm counter-image 3
Counter: 1
Counter: 2
Expand All @@ -374,7 +374,7 @@ Counter: 3

With `docker run -it`, the <kbd>Ctrl+C</kbd> command will stop process that is running in the container, which in turn, stops the container. Since the `--rm` parameter was provided, the container is automatically deleted when the process is stopped. Verify that it doesn't exist:

```Docker
```console
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
```
Expand All @@ -387,7 +387,7 @@ The `docker run` command also lets you modify the `ENTRYPOINT` command from the

In this example, `ENTRYPOINT` is changed to `cmd.exe`. <kbd>Ctrl+C</kbd> is pressed to end the process and stop the container.

```Docker
```console
docker run -it --rm --entrypoint "cmd.exe" counter-image

Microsoft Windows [Version 10.0.17763.379]
Expand Down Expand Up @@ -446,25 +446,25 @@ During this tutorial, you created containers and images. If you want, delete the

01. List all containers

```Docker
```console
docker ps -a
```

02. Stop containers that are running by their name.

```Docker
```console
docker stop counter-image
```

03. Delete the container

```Docker
```console
docker rm counter-image
```

Next, delete any images that you no longer want on your machine. Delete the image created by your *Dockerfile* and then delete the .NET Core image the *Dockerfile* was based on. You can use the **IMAGE ID** or the **REPOSITORY:TAG** formatted string.

```Docker
```console
docker rmi counter-image:latest
docker rmi mcr.microsoft.com/dotnet/core/aspnet:3.1
```
Expand Down
6 changes: 3 additions & 3 deletions docs/core/tutorials/netcore-hosting.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ In this sample, the host can now call `managedDelegate` to run the `ManagedWorke

Alternatively, the `coreclr_execute_assembly` function can be used to launch a managed executable. This API takes an assembly path and array of arguments as input parameters. It loads the assembly at that path and invokes its main method.

```C++
```c++
int hr = executeAssembly(
hostHandle,
domainId,
Expand Down Expand Up @@ -196,7 +196,7 @@ With an `ICLRRuntimeHost4` in-hand, we can now specify runtime-wide startup flag

The runtime is started with a call to the `Start` function.

```C++
```c++
hr = runtimeHost->Start();
```

Expand Down Expand Up @@ -238,7 +238,7 @@ With an AppDomain up and running, the host can now start executing managed code.

Another option, if `ExecuteAssembly` doesn't meet your host's needs, is to use `CreateDelegate` to create a function pointer to a static managed method. This requires the host to know the signature of the method it is calling into (in order to create the function pointer type) but allows hosts the flexibility to invoke code other than an assembly's entry point. The assembly name provided in the second parameter is the [full managed assembly name](../../standard/assembly/names.md) of the library to load.

```C++
```c++
void *pfnDelegate = NULL;
hr = runtimeHost->CreateDelegate(
domainId,
Expand Down
Loading

0 comments on commit 153df0e

Please sign in to comment.