Skip to content

Commit

Permalink
Fixes serversideup#8: Add ability to replace symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
cowwoc committed Nov 9, 2024
1 parent 77277e8 commit ce31440
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 13 deletions.
41 changes: 28 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@
</p>

# Certbot Cloudflare DNS Docker Container

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.

| Docker Image | Size |
|--------------|------|
| Docker Image | Size |
|---------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [**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) |

## Base Image

The image is based on `certbot/dns-cloudflare:latest`, providing a stable and up-to-date environment for running Certbot with Cloudflare DNS authentication.

## Features

- Automatic SSL certificate generation and renewal using Let's Encrypt
- No configs needed, this image generates the cloudflare.ini file for you
- Cloudflare DNS authentication for domain validation
Expand All @@ -30,13 +33,14 @@ The image is based on `certbot/dns-cloudflare:latest`, providing a stable and up

The following environment variables can be used to customize the Certbot container:

| Variable | Description | Default Value |
|----------|-------------|---------------|
| `CERTBOT_DOMAIN` | Domain for which to obtain the certificate | - |
| `CERTBOT_EMAIL` | Email address for Let's Encrypt notifications | - |
| `CERTBOT_KEY_TYPE` | Type of private key to generate | `ecdsa` |
| `CLOUDFLARE_API_TOKEN` | Cloudflare API token for DNS authentication | - |
| `RENEWAL_INTERVAL` | Interval between certificate renewal checks | 43200 seconds (12 hours) |
| Variable | Description | Default Value |
|------------------------|------------------------------------------------------------------|----------------------------|
| `CERTBOT_DOMAIN` | Domain for which to obtain the certificate | - |
| `CERTBOT_EMAIL` | Email address for Let's Encrypt notifications | - |
| `CERTBOT_KEY_TYPE` | Type of private key to generate | `ecdsa` |
| `CLOUDFLARE_API_TOKEN` | Cloudflare API token for DNS authentication | - |
| `RENEWAL_INTERVAL` | Interval between certificate renewal checks | `43200` seconds (12 hours) |
| `REPLACE_SYMLINKS` | Replaces symlinks with direct copies of the files they reference | `false` |

## Usage

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

### Works great for orchestrated deployments

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:

```yaml
Expand All @@ -74,17 +79,19 @@ We designed this image to work great in orchestrated deployments like Kubernetes
CERTBOT_EMAIL: "${CERTBOT_EMAIL}"
CERTBOT_DOMAIN: "${CERTBOT_DOMAIN}"
CERTBOT_KEY_TYPE: "rsa"

volumes:
certbot_data:
```
## Resources
- **[Discord](https://serversideup.net/discord)** for friendly support from the community and the team.
- **[GitHub](https://github.com/serversideup/docker-certbot-dns-cloudflare)** for source code, bug reports, and project management.
- **[Get Professional Help](https://serversideup.net/professional-support)** - Get video + screen-sharing help directly from the core contributors.
## Contributing
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.
- **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).
Expand All @@ -95,24 +102,28 @@ Need help getting started? Join our Discord community and we'll help you out!
<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>
## Our Sponsors
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.
<p 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>
#### Bronze Sponsors
<!-- bronze -->No bronze sponsors yet. <a href="https://github.com/sponsors/serversideup">Become a sponsor →</a><!-- bronze -->
#### Individual Supporters
<!-- 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 -->
## About Us
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.
<div align="center">
| <div align="center">Dan Pastori</div> | <div align="center">Jay Rogers</div> |
| ----------------------------- | ------------------------------------------ |
| <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> |
| <div align="center">Dan Pastori</div> | <div align="center">Jay Rogers</div> |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| <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> |
</div>
Expand All @@ -127,17 +138,21 @@ We're [Dan](https://twitter.com/danpastori) and [Jay](https://twitter.com/jaydro
* **❤️ [Sponsor Us](https://github.com/sponsors/serversideup)** - Please consider sponsoring us so we can create more helpful resources.
## Our products
If you appreciate this project, be sure to check out our other projects.
### 📚 Books
- **[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.
- **[Building Multi-Platform Browser Extensions](https://serversideup.net/building-multi-platform-browser-extensions/)**: Ship extensions to all browsers from the same codebase.
### 🛠️ Software-as-a-Service
- **[Bugflow](https://bugflow.io/)**: Get visual bug reports directly in GitHub, GitLab, and more.
- **[SelfHost Pro](https://selfhostpro.com/)**: Connect Stripe or Lemonsqueezy to a private docker registry for self-hosted apps.
### 🌍 Open Source
- **[AmplitudeJS](https://521dimensions.com/open-source/amplitudejs)**: Open-source HTML5 & JavaScript Web Audio Library.
- **[Spin](https://serversideup.net/open-source/spin/)**: Laravel Sail alternative for running Docker from development → production.
- **[Financial Freedom](https://github.com/serversideup/financial-freedom)**: Open source alternative to Mint, YNAB, & Monarch Money.
27 changes: 27 additions & 0 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,33 @@ run_certbot() {
echo "Error: certbot command failed with exit code $exit_code"
exit 1
fi

if [ "$REPLACE_SYMLINKS" = "true" ]; then
replace_symlinks "/etc/letsencrypt/live";
fi
}

# Replaces all symlinks with direct copies of the files they reference, maintaining the original locations.
replace_symlinks() {
# shellcheck disable=SC3043
local dir="$1"

# Iterate over all items in the directory
for item in "$dir"/*; do
if [ -L "$item" ]; then
# If the item is a symlink
target=$(readlink -f "$item")
if [ -e "$target" ]; then
echo "Replacing symlink $item with a copy of $target"
cp -r "$target" "$item"
else
echo "Warning: target $target of symlink $item does not exist"
fi
elif [ -d "$item" ]; then
# If the item is a directory, process it recursively
replace_symlinks "$item"
fi
done
}

# Run certbot initially
Expand Down

0 comments on commit ce31440

Please sign in to comment.