Skip to content

Commit d1f786d

Browse files
cowwocjaydrogers
andauthored
Fixes #8: Add ability to replace symlinks (#9)
* Fixes #8: Add ability to replace symlinks * Mention that Windows requires REPLACE_SYMLINKS=true * Linked to the WSL bug that REPLACE_SYMLINKS is meant to work around. --------- Co-authored-by: Jay Rogers <[email protected]>
1 parent e80c83b commit d1f786d

File tree

2 files changed

+50
-6
lines changed

2 files changed

+50
-6
lines changed

README.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,25 @@
1010
</p>
1111

1212
# Certbot Cloudflare DNS Docker Container
13+
1314
This container is used to generate and automatically renew SSL certificates from Let's Encrypt using the Cloudflare DNS plugin. It's based off the [official Certbot image](https://hub.docker.com/r/certbot/dns-cloudflare) with some modifications to make it more flexible and configurable.
1415

15-
| Docker Image | Size |
16-
|--------------|------|
16+
| Docker Image | Size |
17+
|---------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1718
| [**serversideup/certbot-dns-cloudflare**](https://hub.docker.com/r/serversideup/certbot-dns-cloudflare) | [![Docker Image Size](https://img.shields.io/docker/image-size/serversideup/certbot-dns-cloudflare/latest?style=flat-square)](https://hub.docker.com/r/serversideup/certbot-dns-cloudflare) |
1819

1920
## Base Image
21+
2022
The image is based on `certbot/dns-cloudflare:latest`, providing a stable and up-to-date environment for running Certbot with Cloudflare DNS authentication.
2123

2224
## Features
25+
2326
- Automatic SSL certificate generation and renewal using Let's Encrypt
2427
- No configs needed, this image generates the cloudflare.ini file for you
2528
- Cloudflare DNS authentication for domain validation
2629
- Customizable configuration via environment variables
2730
- Periodic certificate renewal checks
31+
- Windows support (set `REPLACE_SYMLINKS` to `true`)
2832

2933
## Environment Variables
3034

@@ -37,6 +41,7 @@ The following environment variables can be used to customize the Certbot contain
3741
| `CERTBOT_KEY_TYPE` | Type of private key to generate | `ecdsa` |
3842
| `CLOUDFLARE_API_TOKEN` | Cloudflare API token for DNS authentication | - |
3943
| `RENEWAL_INTERVAL` | Interval between certificate renewal checks | 43200 seconds (12 hours) |
44+
| `REPLACE_SYMLINKS` | Replaces symlinks with direct copies of the files they reference | `false` |
4045

4146
## Usage
4247

@@ -62,6 +67,7 @@ The following environment variables can be used to customize the Certbot contain
6267
3. The container will automatically generate and renew the certificate.
6368

6469
### Works great for orchestrated deployments
70+
6571
We designed this image to work great in orchestrated deployments like Kubernetes, Docker Swarm, or even in Github Actions. Look how simple the syntax is:
6672

6773
```yaml
@@ -74,17 +80,19 @@ We designed this image to work great in orchestrated deployments like Kubernetes
7480
CERTBOT_EMAIL: "${CERTBOT_EMAIL}"
7581
CERTBOT_DOMAINS: "${CERTBOT_DOMAINS}"
7682
CERTBOT_KEY_TYPE: "rsa"
77-
83+
7884
volumes:
7985
certbot_data:
8086
```
8187
8288
## Resources
89+
8390
- **[Discord](https://serversideup.net/discord)** for friendly support from the community and the team.
8491
- **[GitHub](https://github.com/serversideup/docker-certbot-dns-cloudflare)** for source code, bug reports, and project management.
8592
- **[Get Professional Help](https://serversideup.net/professional-support)** - Get video + screen-sharing help directly from the core contributors.
8693
8794
## Contributing
95+
8896
As an open-source project, we strive for transparency and collaboration in our development process. We greatly appreciate any contributions members of our community can provide. Whether you're fixing bugs, proposing features, improving documentation, or spreading awareness - your involvement strengthens the project.
8997
9098
- **Bug Report**: If you're experiencing an issue while using these images, please [create an issue](https://github.com/serversideup/docker-certbot-dns-cloudflare/issues/new/choose).
@@ -95,24 +103,28 @@ Need help getting started? Join our Discord community and we'll help you out!
95103
<a href="https://serversideup.net/discord"><img src="https://serversideup.net/wp-content/themes/serversideup/images/open-source/join-discord.svg" title="Join Discord"></a>
96104
97105
## Our Sponsors
106+
98107
All of our software is free an open to the world. None of this can be brought to you without the financial backing of our sponsors.
99108
100109
<p style="text-align: center"><a href="https://github.com/sponsors/serversideup"><img src="https://521public.s3.amazonaws.com/serversideup/sponsors/sponsor-box.png" alt="Sponsors"></a></p>
101110
102111
#### Bronze Sponsors
112+
103113
<!-- bronze -->No bronze sponsors yet. <a href="https://github.com/sponsors/serversideup">Become a sponsor →</a><!-- bronze -->
104114
105115
#### Individual Supporters
116+
106117
<!-- supporters --><a href="https://github.com/GeekDougle"><img src="https://github.com/GeekDougle.png" width="40px" alt="GeekDougle" /></a>&nbsp;&nbsp;<a href="https://github.com/JQuilty"><img src="https://github.com/JQuilty.png" width="40px" alt="JQuilty" /></a>&nbsp;&nbsp;<a href="https://github.com/MaltMethodDev"><img src="https://github.com/MaltMethodDev.png" width="40px" alt="MaltMethodDev" /></a>&nbsp;&nbsp;<!-- supporters -->
107118
108119
## About Us
120+
109121
We're [Dan](https://twitter.com/danpastori) and [Jay](https://twitter.com/jaydrogers) - a two person team with a passion for open source products. We created [Server Side Up](https://serversideup.net) to help share what we learn.
110122
111123
<div style="text-align: center">
112124
113-
| <div align="center">Dan Pastori</div> | <div align="center">Jay Rogers</div> |
114-
| ----------------------------- | ------------------------------------------ |
115-
| <div align="center"><a href="https://twitter.com/danpastori"><img src="https://serversideup.net/wp-content/uploads/2023/08/dan.jpg" title="Dan Pastori" width="150px"></a><br /><a href="https://twitter.com/danpastori"><img src="https://serversideup.net/wp-content/themes/serversideup/images/open-source/twitter.svg" title="Twitter" width="24px"></a><a href="https://github.com/danpastori"><img src="https://serversideup.net/wp-content/themes/serversideup/images/open-source/github.svg" title="GitHub" width="24px"></a></div> | <div align="center"><a href="https://twitter.com/jaydrogers"><img src="https://serversideup.net/wp-content/uploads/2023/08/jay.jpg" title="Jay Rogers" width="150px"></a><br /><a href="https://twitter.com/jaydrogers"><img src="https://serversideup.net/wp-content/themes/serversideup/images/open-source/twitter.svg" title="Twitter" width="24px"></a><a href="https://github.com/jaydrogers"><img src="https://serversideup.net/wp-content/themes/serversideup/images/open-source/github.svg" title="GitHub" width="24px"></a></div> |
125+
| <div align="center">Dan Pastori</div> | <div align="center">Jay Rogers</div> |
126+
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
127+
| <div align="center"><a href="https://twitter.com/danpastori"><img src="https://serversideup.net/wp-content/uploads/2023/08/dan.jpg" title="Dan Pastori" width="150px"></a><br /><a href="https://twitter.com/danpastori"><img src="https://serversideup.net/wp-content/themes/serversideup/images/open-source/twitter.svg" title="Twitter" width="24px"></a><a href="https://github.com/danpastori"><img src="https://serversideup.net/wp-content/themes/serversideup/images/open-source/github.svg" title="GitHub" width="24px"></a></div> | <div align="center"><a href="https://twitter.com/jaydrogers"><img src="https://serversideup.net/wp-content/uploads/2023/08/jay.jpg" title="Jay Rogers" width="150px"></a><br /><a href="https://twitter.com/jaydrogers"><img src="https://serversideup.net/wp-content/themes/serversideup/images/open-source/twitter.svg" title="Twitter" width="24px"></a><a href="https://github.com/jaydrogers"><img src="https://serversideup.net/wp-content/themes/serversideup/images/open-source/github.svg" title="GitHub" width="24px"></a></div> |
116128
117129
</div>
118130
@@ -127,17 +139,21 @@ We're [Dan](https://twitter.com/danpastori) and [Jay](https://twitter.com/jaydro
127139
* **❤️ [Sponsor Us](https://github.com/sponsors/serversideup)** - Please consider sponsoring us so we can create more helpful resources.
128140
129141
## Our products
142+
130143
If you appreciate this project, be sure to check out our other projects.
131144
132145
### 📚 Books
146+
133147
- **[The Ultimate Guide to Building APIs & SPAs](https://serversideup.net/ultimate-guide-to-building-apis-and-spas-with-laravel-and-nuxt3/)**: Build web & mobile apps from the same codebase.
134148
- **[Building Multi-Platform Browser Extensions](https://serversideup.net/building-multi-platform-browser-extensions/)**: Ship extensions to all browsers from the same codebase.
135149
136150
### 🛠️ Software-as-a-Service
151+
137152
- **[Bugflow](https://bugflow.io/)**: Get visual bug reports directly in GitHub, GitLab, and more.
138153
- **[SelfHost Pro](https://selfhostpro.com/)**: Connect Stripe or Lemonsqueezy to a private docker registry for self-hosted apps.
139154
140155
### 🌍 Open Source
156+
141157
- **[AmplitudeJS](https://521dimensions.com/open-source/amplitudejs)**: Open-source HTML5 & JavaScript Web Audio Library.
142158
- **[Spin](https://serversideup.net/open-source/spin/)**: Laravel Sail alternative for running Docker from development → production.
143159
- **[Financial Freedom](https://github.com/serversideup/financial-freedom)**: Open source alternative to Mint, YNAB, & Monarch Money.

src/entrypoint.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,34 @@ run_certbot() {
5656
echo "Error: certbot command failed with exit code $exit_code"
5757
exit 1
5858
fi
59+
60+
if [ "$REPLACE_SYMLINKS" = "true" ]; then
61+
replace_symlinks "/etc/letsencrypt/live";
62+
fi
63+
}
64+
65+
# Workaround https://github.com/microsoft/wsl/issues/12250 by replacing symlinks with direct copies of the files they
66+
# reference.
67+
replace_symlinks() {
68+
# shellcheck disable=SC3043
69+
local dir="$1"
70+
71+
# Iterate over all items in the directory
72+
for item in "$dir"/*; do
73+
if [ -L "$item" ]; then
74+
# If the item is a symlink
75+
target=$(readlink -f "$item")
76+
if [ -e "$target" ]; then
77+
echo "Replacing symlink $item with a copy of $target"
78+
cp -r "$target" "$item"
79+
else
80+
echo "Warning: target $target of symlink $item does not exist"
81+
fi
82+
elif [ -d "$item" ]; then
83+
# If the item is a directory, process it recursively
84+
replace_symlinks "$item"
85+
fi
86+
done
5987
}
6088

6189
# Run certbot initially

0 commit comments

Comments
 (0)