建立映像时,我试图创建一个签名的ssl证书。但是未创建cert.pfx文件。如果创建了容器并放置了相同的代码来创建证书,则会生成文件
.
FROM microsoft/aspnetcore:2.0 AS base
WORKDIR /app
EXPOSE 1445
EXPOSE 44358
FROM build AS publish
RUN dotnet publish IdentityServer4WithDocker.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "IdentityServer4WithDocker.dll"]
ENV certPassword 1234
# Use opnssl to generate a self signed certificate cert.pfx with password $env:certPassword
RUN openssl genrsa -des3 -passout pass:1234 -out server.key 2048
RUN openssl rsa -passin pass:1234 -in server.key -out server.key
RUN openssl req -sha256 -new -key server.key -out server.csr -subj '/CN=localhost'
RUN openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt
RUN openssl pkcs12 -export -out cert.pfx -inkey server.key -in server.crt -certfile server.crt -passout pass:1234
FROM microsoft/aspnetcore-build:2.0 AS build
WORKDIR /src
COPY IdentityServer4WithDocker/IdentityServer4WithDocker.csproj IdentityServer4WithDocker/
RUN dotnet restore IdentityServer4WithDocker/IdentityServer4WithDocker.csproj
COPY . .
WORKDIR /src/IdentityServer4WithDocker
RUN dotnet build IdentityServer4WithDocker.csproj -c Release -o /app