Skip to content

Commit ed906d5

Browse files
authored
Merge pull request #24 from MB175/feature/docker
Add Dockerized Certbot Setup
2 parents d4a9cc8 + 183211f commit ed906d5

File tree

5 files changed

+96
-0
lines changed

5 files changed

+96
-0
lines changed

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM python:3.11-slim
2+
3+
RUN apt-get update && apt-get install -y \
4+
git \
5+
gcc \
6+
libffi-dev \
7+
libssl-dev \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
RUN pip install certbot
11+
12+
RUN git clone https://github.com/stackitcloud/certbot-dns-stackit.git /opt/certbot-dns-stackit \
13+
&& pip install /opt/certbot-dns-stackit
14+
15+
WORKDIR /etc/letsencrypt
16+
17+
ENTRYPOINT ["certbot"]

examples/.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DOMAIN=example.com
2+
WILDCARD=*.example.com

examples/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.ini

examples/docker-compose.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: '3.8'
2+
3+
services:
4+
certbot:
5+
build:
6+
context: .
7+
dockerfile: ../Dockerfile
8+
container_name: certbot-stackit
9+
volumes:
10+
- ./letsencrypt:/etc/letsencrypt
11+
- ./stackit.ini:/stackit.ini:ro
12+
entrypoint: certbot
13+
command: >
14+
certonly
15+
--agree-tos
16+
--non-interactive
17+
--email dns@${DOMAIN}
18+
--authenticator dns-stackit
19+
--dns-stackit-credentials /stackit.ini
20+
--dns-stackit-propagation-seconds 60
21+
-d "${WILDCARD}" -d "${DOMAIN}"
22+
certbot-renew:
23+
build:
24+
context: .
25+
dockerfile: ../Dockerfile
26+
container_name: certbot-renew
27+
volumes:
28+
- ./letsencrypt:/etc/letsencrypt
29+
- ./stackit.ini:/stackit.ini:ro
30+
entrypoint: certbot
31+
command: renew

examples/readme.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Certbot with Stackit DNS Plugin (Docker Compose)
2+
3+
- Custom Docker image: Based on certbot/certbot, with the Stackit DNS plugin installed.
4+
- Docker Compose service to request wildcard certificates.
5+
6+
---
7+
## 📂 Certificate File Structure
8+
9+
```
10+
./letsencrypt/live/<your-domain>/
11+
├── cert.pem # Your domain’s certificate
12+
├── chain.pem # The Let's Encrypt chain
13+
├── fullchain.pem # cert.pem + chain.pem (what you usually use)
14+
├── privkey.pem # Your private key
15+
```
16+
17+
18+
## 🛠️ Setup Instructions
19+
20+
21+
### 1. Create a file named `stackit.ini` in the root directory:
22+
23+
⚠️️️ Make sure the file is secure: (`chmod 600 stackit.ini`)
24+
```
25+
dns_stackit_auth_token = YOUR_API_TOKEN
26+
dns_stackit_project_id = YOUR_PROJECT_ID
27+
```
28+
29+
### 2. Set domain in `.env` file
30+
```
31+
DOMAIN=example.com
32+
WILDCARD=*.example.com
33+
```
34+
35+
### 3. Run Certbot
36+
```
37+
docker compose up certbot
38+
```
39+
40+
### 4. Cert permission
41+
42+
The certs and the live folder will be `root:root`, in order to access them with your user
43+
```bash
44+
sudo chown -R $(id -u):$(id -g) ./letsencrypt
45+
```

0 commit comments

Comments
 (0)