Skip to content

Commit 57928c3

Browse files
committed
add Dockerfile and docker-compose.yaml
1 parent 7bac5bc commit 57928c3

9 files changed

Lines changed: 94 additions & 31 deletions

File tree

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM ubuntu:18.04
2+
3+
ENV TZ "Asia/Shanghai"
4+
ENV LANG "C.UTF-8"
5+
6+
RUN sed -i 's/archive.ubuntu.com/mirrors.163.com/g' /etc/apt/sources.list && \
7+
sed -i 's/security.ubuntu.com/mirrors.163.com/g' /etc/apt/sources.list && \
8+
echo $TZ > /etc/timezone && \
9+
apt update && DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \
10+
python3-pip python3-setuptools python3-wheel python3.6 tzdata && \
11+
ln -s /usr/bin/python3.6 /usr/bin/python && ln -s /usr/bin/pip3 /usr/bin/pip
12+
13+
RUN mkdir -p /web/logs
14+
WORKDIR /web
15+
16+
ADD requirements.txt /web/requirements.txt
17+
RUN pip3 install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
18+
19+
ADD runserver.py /web/runserver.py
20+
ADD forums /web/forums
21+
ADD templates /web/templates
22+
ADD static /web/static
23+
ADD translations /web/translations
24+
25+
CMD ["gunicorn","-b","0.0.0.0:8000","runserver:app"]

config.example

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Author: jianglin
77
# Email: mail@honmaple.com
88
# Created: 2016-05-20 12:31:46 (CST)
9-
# Last Update: Wednesday 2019-05-08 16:28:02 (CST)
9+
# Last Update: Monday 2022-12-12 16:40:46 (CST)
1010
# By: jianglin
1111
# Description:
1212
# **************************************************************************
@@ -46,11 +46,18 @@ CACHE_REDIS_PASSWORD = 'your password'
4646
CACHE_REDIS_DB = 2
4747

4848
# Redis setting
49-
REDIS = {'db': 1, 'password': 'your password', 'decode_responses': True}
49+
REDIS = {
50+
'host': 'redis',
51+
'db': 1,
52+
'password': 'your password',
53+
'decode_responses': True
54+
}
5055

5156
# some middleware
52-
MIDDLEWARE = ['forums.common.middleware.GlobalMiddleware',
53-
'forums.common.middleware.OnlineMiddleware']
57+
MIDDLEWARE = [
58+
'forums.common.middleware.GlobalMiddleware',
59+
'forums.common.middleware.OnlineMiddleware'
60+
]
5461

5562
# Mail such as qq
5663
MAIL_SERVER = 'smtp.qq.com'

docker-compose.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: "2.2"
2+
services:
3+
redis:
4+
image: redis:alpine
5+
ports:
6+
- 6379:6379
7+
postgres:
8+
image: postgres:10
9+
restart: always
10+
ports:
11+
- 5433:5432
12+
environment:
13+
- POSTGRES_PASSWORD=test
14+
forums:
15+
build:
16+
context: .
17+
ports:
18+
- 8000:8000
19+
links:
20+
- redis
21+
- postgres
22+
depends_on:
23+
- redis
24+
- postgres
25+
volumes:
26+
- ./config.py:/web/config.py

forums/admin/views.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# Copyright © 2016 jianglin
55
# File Name: views.py
66
# Author: jianglin
7-
# Email: xiyang0807@gmail.com
7+
# Email: mail@honmaple.com
88
# Created: 2016-12-17 13:15:10 (CST)
9-
# Last Update: Wednesday 2019-05-08 14:32:26 (CST)
9+
# Last Update: Monday 2022-12-12 16:51:58 (CST)
1010
# By:
1111
# Description:
1212
# **************************************************************************
@@ -29,8 +29,8 @@ class BaseView(ModelView):
2929
can_view_details = True
3030
form_base_class = BaseForm
3131

32-
# def is_accessible(self):
33-
# return super_permission.can()
32+
def is_accessible(self):
33+
return super_permission.can()
3434

35-
# def inaccessible_callback(self, name, **kwargs):
36-
# abort(404)
35+
def inaccessible_callback(self, name, **kwargs):
36+
abort(404)

forums/api/topic/db.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# -*- coding: utf-8 -*-
33
# **************************************************************************
44
# Copyright © 2016 jianglin
5-
# File Name: models.py
5+
# File Name: db.py
66
# Author: jianglin
7-
# Email: xiyang0807@gmail.com
7+
# Email: mail@honmaple.com
88
# Created: 2016-12-15 20:52:07 (CST)
9-
# Last Update: Monday 2019-05-06 23:37:22 (CST)
9+
# Last Update: Monday 2022-12-12 15:22:48 (CST)
1010
# By:
1111
# Description:
1212
# **************************************************************************

forums/extension/maple.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# Copyright © 2018 jianglin
55
# File Name: maple.py
66
# Author: jianglin
7-
# Email: xiyang0807@gmail.com
7+
# Email: mail@honmaple.com
88
# Created: 2018-02-11 14:56:08 (CST)
9-
# Last Update: 星期日 2018-02-11 15:26:53 (CST)
9+
# Last Update: Monday 2022-12-12 16:38:21 (CST)
1010
# By:
1111
# Description:
1212
# ********************************************************************************
@@ -17,17 +17,17 @@
1717
from flask_maple.json import CustomJSONEncoder
1818
from flask_maple.middleware import Middleware
1919
from flask_maple.log import Logging
20+
from PIL import ImageFont
2021

21-
bootstrap = Bootstrap(
22-
css=('styles/monokai.css', 'styles/mine.css'),
23-
js=('styles/upload.js', 'styles/forums.js', 'styles/following.js',
24-
'styles/topic.js'),
25-
use_auth=True)
22+
bootstrap = Bootstrap(css=('styles/monokai.css', 'styles/mine.css'),
23+
js=('styles/upload.js', 'styles/forums.js',
24+
'styles/following.js', 'styles/topic.js'),
25+
use_auth=True)
2626

2727

2828
def init_app(app):
2929
bootstrap.init_app(app)
30-
Captcha(app)
30+
Captcha(app, font=ImageFont.load_default())
3131
Error(app)
3232
App(app, json=CustomJSONEncoder)
3333
Middleware(app)

forums/jinja.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# Copyright © 2016 jianglin
55
# File Name: jinja.py
66
# Author: jianglin
7-
# Email: xiyang0807@gmail.com
7+
# Email: mail@honmaple.com
88
# Created: 2016-11-07 21:00:32 (CST)
9-
# Last Update: Wednesday 2019-05-08 16:26:18 (CST)
9+
# Last Update: Monday 2022-12-12 16:11:32 (CST)
1010
# By:
1111
# Description:
1212
# **************************************************************************
@@ -16,7 +16,7 @@
1616
from bleach import clean
1717
from flask import Markup, g
1818
from flask_babel import format_datetime
19-
from misaka import HtmlRenderer, Markdown
19+
from markdown import markdown as m
2020

2121

2222
def safe_clean(text):
@@ -27,11 +27,10 @@ def safe_clean(text):
2727

2828

2929
def markdown(text, clean=True):
30-
renderer = HtmlRenderer()
31-
md = Markdown(renderer, extensions=('fenced-code', ))
30+
html = m(text, extensions=['markdown.extensions.fenced_code'])
3231
if clean:
33-
return Markup(safe_clean(md(text)))
34-
return Markup(md(text))
32+
return Markup(safe_clean(html))
33+
return Markup(html)
3534

3635

3736
def timesince(dt, default="just now"):

requirements.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@ Flask-Principal==0.4.0
1717
Flask-SQLAlchemy==2.2
1818
Flask-WTF==0.14.2
1919
speaklater==1.3
20-
Pillow==3.2.0
21-
misaka==2.0.0
20+
Pillow==5.4.1
2221
Pygments==2.1
2322
pytz==2018.3
2423
redis==2.10.6
2524
psycopg2-binary==2.7.5
2625
Whoosh==2.7.4
2726
gunicorn==19.9.0
27+
jinja2==3.0.3
28+
itsdangerous==2.0.1
29+
Werkzeug==0.16.1
30+
wtforms==2.3.1
31+
SQLAlchemy==1.3.5
32+
Markdown==3.3.7
33+
email-validator==1.3.0

runserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Author: jianglin
77
# Email: mail@honmaple.com
88
# Created: 2016-10-25 22:01:29 (CST)
9-
# Last Update: Monday 2019-05-06 23:36:53 (CST)
9+
# Last Update: Monday 2022-12-12 15:29:04 (CST)
1010
# By:
1111
# Description:
1212
# **************************************************************************

0 commit comments

Comments
 (0)