From 0dc4be4079c962d14c51df59e2fee539d432cc5f Mon Sep 17 00:00:00 2001 From: Renato Lima Date: Sat, 31 Dec 2022 15:00:46 -0300 Subject: [PATCH] Add built-in HTTPS endpoint in docker container --- src/Mockaco/Docker/Dockerfile | 17 +++++++++++++++-- src/Mockaco/Settings/appsettings.Docker.json | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Mockaco/Docker/Dockerfile b/src/Mockaco/Docker/Dockerfile index fa10791..948cf6c 100644 --- a/src/Mockaco/Docker/Dockerfile +++ b/src/Mockaco/Docker/Dockerfile @@ -1,16 +1,23 @@ FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS base WORKDIR /app EXPOSE 5000 +EXPOSE 5443 FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim AS build + COPY ./src/Mockaco/Mockaco.csproj /src/Mockaco/ +COPY ./src/Mockaco.AspNetCore/Mockaco.AspNetCore.csproj /src/Mockaco.AspNetCore/ + WORKDIR /src/Mockaco RUN dotnet restore + WORKDIR /repo COPY ./ ./ + WORKDIR /repo/src/Mockaco RUN dotnet build "Mockaco.csproj" -c Release -o /app/build RUN find -iname gitversion.json -exec cat {} \; +RUN dotnet dev-certs https FROM build AS publish RUN dotnet publish "Mockaco.csproj" -c Release -o /app/publish @@ -19,9 +26,15 @@ FROM base AS final ENV DOTNET_USE_POLLING_FILE_WATCHER=true ENV ASPNETCORE_ENVIRONMENT=Docker WORKDIR /app + COPY --from=publish /app/publish . -COPY ./src/Mockaco/Mocks/hello.json /app/Mocks/ -COPY ./src/Mockaco/Settings /app/Settings +COPY ./src/Mockaco/Mocks/hello.json ./Mocks/ +COPY ./src/Mockaco/Settings ./Settings + +COPY --from=build /root/.dotnet/corefx/cryptography/x509stores/my /root/.dotnet/corefx/cryptography/x509stores/my + VOLUME /app/Mocks VOLUME /app/Settings +VOLUME /root/.dotnet/corefx/cryptography/x509stores/my + ENTRYPOINT ["dotnet", "Mockaco.dll"] \ No newline at end of file diff --git a/src/Mockaco/Settings/appsettings.Docker.json b/src/Mockaco/Settings/appsettings.Docker.json index 0b50901..b8b7b14 100644 --- a/src/Mockaco/Settings/appsettings.Docker.json +++ b/src/Mockaco/Settings/appsettings.Docker.json @@ -1,5 +1,5 @@ { - "Urls": "http://+:5000", + "Urls": "http://+:5000;https://+:5443", "Mockaco": { "TemplateFileProvider": { "Path": "Mocks"