docker部署,参考leanote-docker

导入镜像包

1
2
3
4
5
6
7
root@debian:~/tmp# docker load -i leanote-2.6.1_mongo-4.4.11.tar 
Loaded image: leanote:2.6.1
Loaded image: mongo:4.4.11
root@debian:~/tmp# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
leanote 2.6.1 55b689c5ba3a 10 months ago 70.5MB
mongo 4.4.11 1c0f1e566fec 20 months ago 438MB

目录示例

1
2
root@debian:/docker/leanote# ls
app.conf compose.yml dbinit.sh leanote_install_data leanote.js

leanote_install_data

1
2
root@debian:~/tmp# git clone https://github.com/leanote/leanote.git
root@debian:~/tmp# cp -a leanote/mongodb_backup/leanote_install_data/ /docker/leanote

app.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#------------------------
# leanote config
#------------------------

http.addr=0.0.0.0 # listen on all ip addresses
http.port=9000

site.url=http://leanote.domain.xyl # or http://x.com:8080, http://www.xx.com:9000

# admin username
adminUsername=admin

# mongdb
db.host=mongo
db.port=27017
db.dbname=leanote # required
db.username=leanote # if not exists, please leave it blank
db.password=leanote # if not exists, please leave it blank
# or you can set the mongodb url for more complex needs the format is:
# mongodb://myuser:mypass@localhost:40001,otherhost:40001/mydb
# db.url=mongodb://root:root123@localhost:27017/leanote
# db.urlEnv=${MONGODB_URL} # set url from env. eg. mongodb://root:root123@localhost:27017/leanote

# You Must Change It !! About Security!!
app.secret=LfzoXrIvdfsfsdhfkshfgghiurbcbjvjdsfNgz03Nj #

#--------------------------------
# revel config
# for dev
#--------------------------------
app.name=leanote
http.ssl=false
cookie.httponly=false
cookie.prefix=LEANOTE
cookie.domain= # for share cookie with sub-domain
cookie.secure=false
session.expires=3h # 3 hour. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
format.date=2006-01-02
format.datetime=2006-01-02 15:04:05 # 必须这样配置
results.chunked=false

log.trace.prefix = "TRACE "
log.info.prefix = "INFO "
log.warn.prefix = "WARN "
log.error.prefix = "ERROR "

# The default language of this application.
i18n.default_language=zh-cn

module.static=github.com/revel/modules/static

[dev]
mode.dev=true
results.pretty=true
watch=true

module.testrunner = # github.com/revel/modules/testrunner

log.trace.output = stderr
log.info.output = stderr
log.warn.output = stderr
log.error.output = stderr

[prod]
mode.dev=false
results.pretty=false
watch=false

module.testrunner =

log.trace.output = off
log.info.output = off
log.warn.output = stderr
log.error.output = stderr

compose.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
version: '3'
services:
mongo:
image: mongo:4.4.11
restart: always
container_name: mongo
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: leanote
MONGO_INITDB_DATABASE: leanote
deploy:
resources:
limits:
memory: 200M
reservations:
memory: 50M
volumes:
- ./mongodb:/data/db
- /etc/localtime:/etc/localtime
- ./leanote_install_data:/leanote_install_data
- ./dbinit.sh:/docker-entrypoint-initdb.d/dbinit.sh
- ./leanote.js:/leanote.js
networks:
- leanote
ports:
- 27017:27017
leanote:
image: leanote:2.6.1
container_name: leanote
depends_on:
- mongo
restart: always
volumes:
- /etc/localtime:/etc/localtime
- ./datas/files:/leanote/files
- ./datas/upload:/leanote/public/upload
- ./app.conf:/leanote/conf/app.conf
networks:
- leanote
ports:
- 9000:9000
networks:
leanote:
driver: bridge

dbinit.sh

1
2
mongorestore -h localhost -d leanote --dir /leanote_install_data
mongo -u admin -p leanote 127.0.0.1:27017/admin /leanote.js

leanote.js

1
2
db = db.getSiblingDB("leanote");
db.createUser({user:"leanote",pwd:"leanote",roles:[{role:"readWrite",db:"leanote"}]});

启动

1
2
3
4
5
6
7
8
9
10
root@debian:/docker/leanote# docker compose up -d
[+] Running 3/3
✔ Network leanote_leanote Created 0.1s
✔ Container mongo Started 0.3s
✔ Container leanote Started 0.6s
root@debian:/docker/leanote# docker compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
leanote leanote:2.6.1 "/leanote/bin/run.sh" leanote 5 seconds ago Up 4 seconds 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp
mongo mongo:4.4.11 "docker-entrypoint.s…" mongo 5 seconds ago Up 5 seconds 0.0.0.0:27017->27017/tcp, :::27017->27017/tcp

部署后可以只保留以下文件

1
2
3
4
5
6
7
8
9
10
11
12
13
root@debian:/docker/leanote# sed -i -e '/dbinit.sh/d' -e '/leanote\.js/d' -e '/leanote_install_data/d' compose.yml
root@debian:/docker/leanote# rm -rf leanote_install_data/ dbinit.sh leanote.js
root@debian:/docker/leanote# ls
app.conf compose.yml datas mongodb
root@debian:/docker/leanote# docker compose down && docker compose up -d
[+] Running 3/3
✔ Container leanote Removed 10.3s
✔ Container mongo Removed 0.3s
✔ Network leanote_leanote Removed 0.2s
[+] Running 3/3
✔ Network leanote_leanote Created 0.1s
✔ Container mongo Started 0.3s
✔ Container leanote Started 0.5s

nginx代理配置参考

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
server {
listen 80;
server_name leanote.domain.xyl;
rewrite ^/(.*) https://$server_name/$1 permanent;
# location / {
# proxy_pass http://leanote;
# }
}

server {
listen 443 ssl;
server_name leanote.domain.xyl;
server_tokens off;
access_log /docker/app/leanote/access_nginx.log main;
error_log /dev/null emerg;

ssl_certificate ssl/leanote.domain.xyl.crt; # Change this path to point a.com.crt, same below.
ssl_certificate_key ssl/leanote.domain.xyl.key;
ssl_session_timeout 1h;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
#客户端认证
ssl_client_certificate ssl/ca.crt;
ssl_verify_client on;

client_max_body_size 1024m;

location / {
proxy_pass http://leanote;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

}

体验

初始用户

1
2
user1 username: admin, password: abc123 (管理员, 只有该用户才有权管理后台, 请及时修改密码)
user2 username: demo@leanote.com, password: demo@leanote.com (仅供体验使用)

访问

http://ip:9000/login

示例

登录
主页

leanote官网可以下载各终端平台客户端