Last active
October 22, 2020 11:38
-
-
Save ahmedig/80c0bef6e8c200743bfdb7ad6f46eda4 to your computer and use it in GitHub Desktop.
Docker file for a dotnet new react project
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
# Pull down an image from Docker Hub that includes the .NET core SDK: | |
# https://hub.docker.com/_/microsoft-dotnet-core-sdk | |
# This is so we have all the tools necessary to compile the app. | |
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build | |
# Fetch and install Node 10. Make sure to include the --yes parameter | |
# to automatically accept prompts during install, or it'll fail. | |
RUN curl --silent --location https://deb.nodesource.com/setup_10.x | bash - | |
RUN apt-get install --yes nodejs | |
# Copy the source from your machine onto the container. | |
WORKDIR /src | |
COPY . . | |
# Install dependencies. | |
# https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-restore?tabs=netcore2x | |
RUN dotnet restore "./azurediy.csproj" | |
# Compile, then pack the compiled app and dependencies into a deployable unit. | |
# https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish?tabs=netcore21 | |
RUN dotnet publish "azurediy.csproj" -c Release -o /app/publish | |
# Pull down an image from Docker Hub that includes only the ASP.NET core runtime: | |
# https://hub.docker.com/_/microsoft-dotnet-core-aspnet/ | |
# We don't need the SDK anymore, so this will produce a lighter-weight image | |
# that can still run the app. | |
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim | |
# Expose port 80 to your local machine so you can access the app. | |
EXPOSE 80 | |
# Copy the published app to this new runtime-only container. | |
COPY --from=build /app/publish . | |
# To run the app, run `dotnet azurediy.dll`, which we just copied over. | |
ENTRYPOINT ["dotnet", "azurediy.dll"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to replace "my-new-app" with the name of your project
Put this file in the root of the folder
Run: