-
Notifications
You must be signed in to change notification settings - Fork 747
Add Aspire.Hosting.Certbot integration for Certbot container support #13248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
4611271
41ca003
ac3b0f7
3d6ccad
87bb3cd
67cbe2d
793c0ae
ad1b0c7
1a7c32d
a5aac1d
b2f5493
e6bba87
2b408c0
9cd0d37
e7b75bc
ed7ec9e
44d566d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,15 +24,15 @@ var certbot = builder.AddCertbot("certbot", domain, email) | |
| .WithHttp01Challenge(); | ||
|
|
||
| var myService = builder.AddContainer("myservice", "myimage") | ||
| .WithCertificateVolume(certbot) | ||
| .WaitForCompletion(certbot); | ||
| .WithCertbotCertificate(certbot); | ||
| ``` | ||
|
|
||
| The certbot container will: | ||
|
|
||
| - Obtain certificates for the specified domain using the ACME protocol | ||
| - Store certificates in a shared volume at `/etc/letsencrypt` | ||
| - Use the configured challenge method (e.g., HTTP-01) for domain validation | ||
| - Ensure dependent containers wait for certificate acquisition before starting | ||
|
|
||
| ## Configuration | ||
|
|
||
|
|
@@ -76,12 +76,23 @@ Certificate permissions are automatically set to allow non-root containers to re | |
|
|
||
| ### Sharing Certificates with Other Resources | ||
|
|
||
| Use the `WithCertificateVolume` extension method to mount the certificates volume in other containers: | ||
| Use the `WithCertbotCertificate` extension method to configure a container with certificates from Certbot: | ||
|
|
||
| ```csharp | ||
| var yarp = builder.AddContainer("yarp", "myimage") | ||
| .WithCertificateVolume(certbot) | ||
| .WaitForCompletion(certbot); | ||
| .WithCertbotCertificate(certbot); | ||
| ``` | ||
|
|
||
| This method automatically: | ||
| - Mounts the certificates volume at `/etc/letsencrypt` | ||
| - Ensures the container waits for certificate acquisition to complete | ||
|
|
||
| For more control, you can use `WithCertificateVolume` and `WaitForCompletion` separately: | ||
|
|
||
| ```csharp | ||
| var myService = builder.AddContainer("myservice", "myimage") | ||
| .WithCertificateVolume(certbot) | ||
| .WaitForCompletion(certbot); | ||
| ``` | ||
|
|
||
| Or mount the volume directly: | ||
|
|
@@ -92,6 +103,8 @@ var myService = builder.AddContainer("myservice", "myimage") | |
| .WaitForCompletion(certbot); | ||
| ``` | ||
|
|
||
| **Important:** Do not use `WithCertbotCertificate` or `WithCertificateVolume` together with `WithServerAuthenticationCertificateConfiguration` on the same resource, as they may conflict. Choose one certificate configuration method per resource. | ||
|
||
|
|
||
| ### Certificate Locations | ||
|
|
||
| After Certbot obtains certificates, they are available at: | ||
|
|
@@ -114,7 +127,7 @@ var privateKeyPath = certbot.Resource.PrivateKeyPath; // /etc/letsencrypt/li | |
|
|
||
| The Certbot resource does not expose connection properties through `WithReference`. This is because the Certbot resource is a certificate provisioning tool, not a service that other resources connect to. | ||
|
|
||
| Instead, use the `WithCertificateVolume` extension method to share certificates with other containers via a mounted volume. See the [Sharing Certificates with Other Resources](#sharing-certificates-with-other-resources) section above for usage examples. | ||
| Instead, use the `WithCertbotCertificate` extension method to configure containers with certificates from Certbot. This method handles mounting the certificates volume and waiting for certificate acquisition. See the [Sharing Certificates with Other Resources](#sharing-certificates-with-other-resources) section above for usage examples. | ||
|
|
||
| ## Additional documentation | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WithServerAuthenticationCertificateConfigurationwas renamed toWithHttpsCertificateConifgurationin main. Also, this comment should referenceWithHttpsCertificateandWithHttpsDeveloperCertificateinstead of the configuration callback API. Instead of telling users they can't use both APIs, we should instruct them not to use both at runtime; it's totally okay to use certbot andWithHttpsCertificateif certbot is only added when running in publish mode.We should also add a note that the user needs to configure their application manually when using certbot (ideally with an example of configuring something like yarp via environment variables). The example should probably wrap the certbot config in a publish mode check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot implement this feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated documentation in commit e6bba87:
WithServerAuthenticationCertificateConfigurationtoWithHttpsCertificateandWithHttpsCertificateConfigurationExecutionContext.IsPublishModecheck