Skip to content

Commit

Permalink
Merge pull request #5 from ghostry/master
Browse files Browse the repository at this point in the history
docker 使用方式修改
  • Loading branch information
0xJacky authored Jun 22, 2024
2 parents 5706571 + f78a070 commit 3a5238b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@ FROM python:latest

WORKDIR /app
COPY ./requirements.txt ./requirements.txt
COPY ./cdncert.py ./cdncert.py
COPY ./config-template.ini ./config-template.ini
COPY ./core.py ./core.py
COPY ./cron.py ./cron.py
COPY ./database.py ./database.py
COPY ./logger.py ./logger.py
COPY ./mail.py ./mail.py
COPY ./settings.py ./settings.py

RUN cd /app && pip install -r requirements.txt
ENTRYPOINT ["python3", "cron.py"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
3. 运行 Docker

```
docker run -dit -v ${cdn_cert项目的绝对路径}:/app \
docker run -dit -v ${配置和数据库文件目录}:/app/data \
-v ${证书文件夹的绝对路径}:/cert \
--name=cdn_cert -e "TZ=Asia/Shanghai" \
cdn_cert /bin/bash
Expand Down
4 changes: 2 additions & 2 deletions config-template.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[database]
Path=cert.db
Path=data/cert.db

[letencrypt]
Path=/cert
Expand All @@ -12,4 +12,4 @@ Port=465
UserName=
PassWord=
From=
To=
To=
2 changes: 2 additions & 0 deletions mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def send(self, subject, content):
# 构建alternative的text/plain部分
textplain = MIMEText(content, _subtype='plain', _charset='UTF-8')
self.msg.attach(textplain)
if settings.UserName is None :
return
# 发送邮件
try:
if settings.Port == 80:
Expand Down
8 changes: 6 additions & 2 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
# -*- coding:utf-8 -*-
import os
import configparser

dataDir = 'data'
if not os.path.isfile(dataDir):
os.path.isfile(dataDir)
if not os.path.isfile(dataDir + '/config.ini'):
os.system('cp config-template.ini ' + dataDir + '/config.ini')
config = configparser.ConfigParser()
config.read('config.ini')
config.read(dataDir + '/config.ini')
# 数据存储地址
ABS_PATH = os.path.split(os.path.realpath(__file__))[0]
DB_PATH = os.path.join(ABS_PATH, config['database']['Path'])
Expand Down

0 comments on commit 3a5238b

Please sign in to comment.