framework
This commit is contained in:
8
Dockerfile
Normal file
8
Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
FROM python:latest
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY . /app
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
ENTRYPOINT ["python", "certman.py"]
|
||||||
|
CMD ["--help"]
|
||||||
20
certman.py
20
certman.py
@@ -0,0 +1,20 @@
|
|||||||
|
from schemas import DomainRequest
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
def request_certificate(domain_request: DomainRequest):
|
||||||
|
domain = domain_request.domain
|
||||||
|
credentials_file = domain_request.credentials_file
|
||||||
|
email = domain_request.email
|
||||||
|
certbot_command = [
|
||||||
|
'certbot', 'certonly',
|
||||||
|
'--dns-cloudflare',
|
||||||
|
'--dns-cloudflare-credentials', credentials_file,
|
||||||
|
'--email', email,
|
||||||
|
'--agree-tos',
|
||||||
|
'--non-interactive',
|
||||||
|
'-d', domain,
|
||||||
|
]
|
||||||
|
result = subprocess.run(certbot_command, capture_output=True, text=True)
|
||||||
|
if result.returncode != 0:
|
||||||
|
raise RuntimeError(f'Certbot returned non-zero exit code:\n{result.stderr}')
|
||||||
|
return result.stdout
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
certbot==5.4.0
|
certbot==5.4.0
|
||||||
certbot-dns-cloudflare==5.4.0
|
certbot-dns-cloudflare==5.4.0
|
||||||
|
pydantic==2.12.5
|
||||||
6
schemas.py
Normal file
6
schemas.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from pydantic import BaseModel, FilePath, EmailStr
|
||||||
|
|
||||||
|
class DomainRequest(BaseModel):
|
||||||
|
domain: str
|
||||||
|
credentials_file: FilePath
|
||||||
|
email: EmailStr
|
||||||
Reference in New Issue
Block a user