Skip to content

Instantly share code, notes, and snippets.

@fakhrulhilal
Created January 16, 2023 08:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fakhrulhilal/261c07467378032a4180d63621516b39 to your computer and use it in GitHub Desktop.
Save fakhrulhilal/261c07467378032a4180d63621516b39 to your computer and use it in GitHub Desktop.
Docker image for .NET with nodejs
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