forked from Azure-Samples/dotnetcore-docs-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Azure-Samples#3 from sadukie/master
Adding Docker files for Linux and Windows for Azure App Service .NET Core sample app
- Loading branch information
Showing
5 changed files
with
91 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Start with the .NET SDK for building the app | ||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build | ||
# Work within a folder named `/source` | ||
WORKDIR /source | ||
|
||
# Copy everything in this project and build app | ||
COPY . ./dotnetcore-docs-hello-world/ | ||
WORKDIR /source/dotnetcore-docs-hello-world | ||
RUN dotnet publish -c release -o /app | ||
|
||
# final stage/image | ||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 | ||
WORKDIR /app | ||
COPY --from=build /app ./ | ||
|
||
# Expose port 80 | ||
# This is important in order for the Azure App Service to pick up the app | ||
ENV PORT 80 | ||
EXPOSE 80 | ||
|
||
# Start the app | ||
ENTRYPOINT ["dotnet", "dotnetcoresample.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Start with the .NET SDK for building the app | ||
# Using an explicit Windows Server tag | ||
# We are using Windows Nanoserver, a headless server for hosting apps with IIS | ||
FROM mcr.microsoft.com/dotnet/sdk:6.0-nanoserver-ltsc2022 AS build | ||
# Work within a folder named `/source` | ||
WORKDIR /source | ||
|
||
# Copy everything in this project and build app | ||
COPY . ./dotnetcore-docs-hello-world/ | ||
WORKDIR /source/dotnetcore-docs-hello-world | ||
RUN dotnet publish -c release -o /app | ||
|
||
# final stage/image | ||
# We're using a tag that is explicitly a Windows container | ||
FROM mcr.microsoft.com/dotnet/aspnet:6.0.6-nanoserver-ltsc2022 | ||
|
||
WORKDIR /app | ||
COPY --from=build /app ./ | ||
|
||
# Expose port 80 | ||
# This is important in order for the Azure App Service to pick up the app | ||
ENV PORT 80 | ||
EXPOSE 80 | ||
|
||
# Start the app | ||
ENTRYPOINT ["dotnet", "dotnetcoresample.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
@page | ||
@model IndexModel | ||
@{ | ||
@{ | ||
ViewData["Title"] = "Home page"; | ||
} | ||
|
||
<div class="text-center"> | ||
<h1 class="display-4">Hello World from .Net 6</h1> | ||
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p> | ||
<hr /> | ||
<div>Host operating system: @Model.OSVersion</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,39 @@ | ||
# .Net 6 Hello World | ||
# .NET 6 Hello World | ||
|
||
This sample demonstrates a tiny Hello World .NET Core app for [App Service Web App](https://docs.microsoft.com/azure/app-service-web). | ||
This sample demonstrates a tiny Hello World .NET Core app for [App Service Web App](https://docs.microsoft.com/azure/app-service-web). This sample can be used in a .NET Azure App Service app as well as in a Custom Container Azure App Service app. | ||
|
||
## Log in to Azure Container Registry | ||
|
||
Using the Azure CLI, log in to the Azure Container Registry (ACR): | ||
|
||
```azurecli | ||
az acr login -n <your_registry_name> | ||
``` | ||
|
||
## Running in a Docker Container | ||
|
||
This repository contains 2 Dockerfiles, a Linux container and a Windows container. | ||
|
||
### Publish the Windows image to your Registry | ||
|
||
To build the Windows image locally and publish to ACR, run the following command: | ||
|
||
```docker | ||
docker build -f Dockerfile.windows -t dotnetcore-docs-hello-world-windows . | ||
docker tag dotnetcore-docs-hello-world-windows <your_registry_name>.azurecr.io/dotnetcore-docs-hello-world-windows:latest | ||
docker push <your_registry_name>.azurecr.io/dotnetcore-docs-hello-world-windows:latest | ||
``` | ||
|
||
### Publish the Linux image to your Registry | ||
|
||
To build the Windows image locally and publish to ACR, run the following command: | ||
|
||
```docker | ||
docker build -f Dockerfile.linux -t dotnetcore-docs-hello-world-linux . | ||
docker tag dotnetcore-docs-hello-world-windows <your_registry_name>.azurecr.io/dotnetcore-docs-hello-world-linux:latest | ||
docker push <your_registry_name>.azurecr.io/dotnetcore-docs-hello-world-linux:latest | ||
``` | ||
|
||
# Contributing | ||
|
||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. | ||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. |