natemcmaster / LettuceEncrypt

Free, automatic HTTPS certificate generation for ASP.NET Core web apps
https://nuget.org/packages/LettuceEncrypt
Apache License 2.0
1.55k stars 152 forks source link

Using with Docker and volumes. #298

Closed MiroslavBonchevBonchev closed 1 month ago

MiroslavBonchevBonchev commented 1 month ago

Hi, I just started using the project and containers, and probably do some error(s). Could you please advise?

I could not get the version before 1.3.3 (I think it was 1.3.2) to work with YARP in docker container out of the box ASIS at all.

The new version 1.3.3 works with YARP deployed as docker container ASIS using the settings as advised on the webpage. There are some errors in the traces, but then it sorts out itself and works great. These are the errors:

fail: LettuceEncrypt.Internal.AcmeStates.ServerStartupState[0] Failed to automatically create a certificate for [DOMAIN.TLD] ...

Removing the question as I got it to work. For anyone that needs the library for docker containers. See below.

MiroslavBonchevBonchev commented 1 month ago
  1. Add the following line to the last section of the Dockerfile FROM base AS final # already there WORKDIR /app/new_cert # add line WORKDIR /app # already there COPY --from=publish /app/publish . # already there

  2. Add to Program.cs builder.Services.AddLettuceEncrypt().PersistDataToDirectory( new DirectoryInfo( "/app/new_cert" ), "Password123" );

The path here must match the path in the Dockerfile

  1. Map your volume in the docker-compose.yml volumes:
    • volume_name:/app/new_cert

The path here must match the path in the Dockerfile

  1. Update your appSettings for the LettuceEncrypt library, or use the programmatic way to set them as required.

Thanks to everyone in questions: #14 & #69 for setting me on the right path to get the library working, and thanks for the great library.