.Net
Net 8
Dockerfile
FROM ghcr.io/architecture-it/net-sdk:8.0 AS publish
WORKDIR /app
COPY . .
WORKDIR "/app/src/Api"
RUN dotnet publish "{appname}.csproj" -c Release -o /app/publish
FROM ghcr.io/architecture-it/net:8.0
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "{appname}.dll"]
A tener en cuenta
- Se debe reemplazar
{appname}
por el nombre de su proyecto principal.
- El container expone en el puerto 8080
Net 6 (Mantenimiento)
Dockerfile
FROM ghcr.io/architecture-it/net:6.0-sdk as build
WORKDIR /app
COPY . .
RUN dotnet restore
WORKDIR "/app/src/Api"
RUN dotnet build "{appname}.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "{appname}.csproj" -c Release -o /app/publish
FROM ghcr.io/architecture-it/net:6.0
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "{appname}.dll"]
Configuración no soportadas
Net 5 (Deprecado)
Dockerfile
FROM ghcr.io/architecture-it/net:5.0-sdk as build
WORKDIR /app
COPY . .
RUN dotnet restore
WORKDIR "/app/src/Api"
RUN dotnet build "{appname}.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "{appname}.csproj" -c Release -o /app/publish
FROM ghcr.io/architecture-it/net:5.0
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "{appname}.dll"]
.NET core 3.1 (Deprecado)
Dockerfile
FROM ghcr.io/architecture-it/net:3.1-sdk as build
WORKDIR /app
COPY . .
RUN dotnet restore
WORKDIR "/app/src/Api"
RUN dotnet build "{appname}.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "{appname}.csproj" -c Release -o /app/publish
FROM ghcr.io/architecture-it/net:3.1
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "{appname}.dll"]
Dockerfile fuera de estandar (Deprecado)
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 8080
# Don't download/extract docs for nuget packages
ENV NUGET_XMLDOC_MODE skip
# Don't do initially populate of package cache
ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE true
ARG nugetUser
ARG nugetToken
ENV NUGET_USER ${nugetUser}
ENV NUGET_TOKEN ${nugetToken}
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
USER root
COPY . .
RUN dotnet nuget locals -c all
RUN dotnet nuget add source https://nuget.pkg.github.com/architecture-it/index.json -n Github -u "$NUGET_USER" -p "$NUGET_TOKEN" --store-password-in-clear-text
RUN dotnet restore
WORKDIR "/src/src/{appname}"
RUN dotnet build "{appname}.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "{appname}.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
ENV TZ=America/Argentina/Buenos_Aires
RUN sed -i 's/TLSv1.2/TLSv1.0/g' /etc/ssl/openssl.cnf
ENV Kestrel__EndPoints__Http__Url=http://+:8080
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "{appname}.dll"]