Created
January 16, 2023 08:30
-
-
Save fakhrulhilal/261c07467378032a4180d63621516b39 to your computer and use it in GitHub Desktop.
Docker image for .NET with nodejs
This file contains hidden or 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
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base | |
WORKDIR /app | |
EXPOSE 80 | |
EXPOSE 443 | |
ENV ASPNETCORE_URLS "https://+,http://+" | |
ENV ASPNETCORE_HTTPS_PORT 443 | |
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build | |
ENV NODE_VERSION 18.x | |
RUN apt-get -y update \ | |
&& apt-get install -y curl \ | |
&& curl -sL https://deb.nodesource.com/setup_$NODE_VERSION | bash - \ | |
&& apt-get install -y nodejs \ | |
&& apt-get clean \ | |
&& echo 'node verions:' $(node -v) \ | |
&& echo 'npm version:' $(npm -v) \ | |
&& echo 'dotnet version:' $(dotnet --version) | |
WORKDIR /src | |
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT 1 | |
COPY ["project/My.App.csproj", "project/"] | |
COPY . . | |
WORKDIR "/src/project" | |
RUN dotnet restore | |
RUN dotnet build --no-restore -c Release -o /app/build | |
FROM build AS publish | |
RUN dotnet publish --no-restore -c Release -o /app/publish | |
FROM base AS final | |
WORKDIR /app | |
COPY --from=publish /app/publish . | |
ENTRYPOINT ["dotnet", "My.App.dll"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment