docker安装HedgeDoc/CodiMD/HackMD

HedgeDoc介绍

HedgeDoc是一款在线Markdown软件,它的强大之处在于可以协作编写文档。

HedgeDoc的前身是codiMD,即hackMD的社区版分支(hackMD CE),它的历史:HedgeDoc History

HedgeDoc的官网主页:HedgeDoc

关于HedgeDoc的前身的介绍:CodiMd

安装教程

官方教程:
1
2
3
git clone https://github.com/hedgedoc/container.git hedgedoc-container
cd hedgedoc-container
docker-compose up

hedgedoc-container文件下有官方给定的构建文件docker-compose.yml,可以自定义修改后使用docker-compose up -d创建并运行容器

自定义HedgeDoc

我们在官方给出的docker-compose.yml文件中

  • 使用MySQL数据库
  • 利用顶级secrets的子键file替换明文用户密码、mysql的URL链接
docker-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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Using version 3 to provide play-with-docker badge
# You can change to version 2 without breaking.
#version: '2'
version: '3.5'
services:
# database:
# Don't upgrade PostgreSQL by simply changing the version number
# You need to migrate the Database to the new PostgreSQL version
# image: postgres:9.6-alpine
#mem_limit: 256mb # version 2 only
#memswap_limit: 512mb # version 2 only
#read_only: true # not supported in swarm mode please enable along with tmpfs
#tmpfs:
# - /run/postgresql:size=512K
# - /tmp:size=256K
# environment:
# - POSTGRES_USER=hedgedoc
# - POSTGRES_PASSWORD=password
# - POSTGRES_DB=hedgedoc
# volumes:
# - database:/var/lib/postgresql/data
# networks:
# backend:
# restart: always

# MySQL example
# Most of the documentation that applies to PostgreSQL applies also to MySQL
database:
# # You should be able to upgrade MySQL without problems
# # but to make sure no even when a problem appears you
# # should have a backup
image: mariadb:10
container_name: hedgedoc_db
environment:
# - MYSQL_USER_FILE=/run/secrets/dbuser
# - MYSQL_PASSWORD_FILE=/run/secrets/dbpassword
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/dbrootpassword
- MYSQL_USER_FILE=/run/secrets/dbuser
- MYSQL_PASSWORD_FILE=/run/secrets/dbpassword
- MYSQL_DATABASE=hedgedoc
- MYSQL_ALLOW_EMPTY_PASSWORD=true
volumes:
- database:/var/lib/mysql
# # This config provides UTF-8 support to the database by default
# # If this config is not used, HedgeDoc breaks as it tries to write
# # UTF-8 to a latin database.
- ./resources/utf8.cnf:/etc/mysql/conf.d/utf8.cnf
networks:
backend:
restart: always
# secret names in this service
secrets:
- dbuser
- dbpassword
- dbrootpassword

hedgedoc:
# Uncomment the following section to build the image yourself:
#build:
# context: .
# dockerfile: debian/Dockerfile
# args:
# - "VERSION=master"
# - "HEDGEDOC_REPOSITORY=https://github.com/hedgedoc/hedgedoc.git"
image: quay.io/hedgedoc/hedgedoc:1.7.2
container_name: hedgedoc
#mem_limit: 256mb # version 2 only
#memswap_limit: 512mb # version 2 only
#read_only: true # not supported in swarm mode, enable along with tmpfs
#tmpfs:
# - /tmp:size=10M
# # Make sure you remove this when you use filesystem as upload type
# - /hedgedoc/public/uploads:size=10M
environment:
# DB_URL is formatted like: <databasetype>://<username>:<password>@<hostname>:<port>/<database>
# Other examples are:

# - For details see the official sequelize docs: http://docs.sequelizejs.com/en/v3/
# - sqlite:///data/sqlite.db (NOT RECOMMENDED)
# - CMD_DB_URL=mysql://hedgedoc:password@database:3306/hedgedoc
# - CMD_DB_URL=postgres://hedgedoc:password@database:5432/hedgedoc

# ATTITION: CMD_DB_URL will be meaningless when secret dbURL is defined. it can be deleted.
# DB_URL has been passed via secret dbURL, see resources/docker-entrypoint.sh line 18
- CMD_DB_URL=/run/secrets/dbURL
volumes:
- uploads:/hedgedoc/public/uploads
# ports:
# # Ports that are published to the outside.
# # The latter port is the port inside the container. It should always stay on 3000
# # If you only specify a port it'll published on all interfaces. If you want to use a
# # local reverse proxy, you may want to listen on 127.0.0.1.
# # Example:
# # - "127.0.0.1:3000:3000"
# - "3000:3000"
ports:
- "88:3000"
networks:
backend:
restart: always
depends_on:
- database
# secret names in this service
secrets:
- dbURL


# Define networks to allow best isolation
networks:
# Internal network for communication with PostgreSQL/MySQL
backend:

# Define named volumes so data stays in place
# volumes:
# # Volume for PostgreSQL/MySQL database
# database:
# driver_opts:
# type: ext4
# o: bind
# device: "/home/deepin/Applications/hedgedoc-container/database"
# uploads:
# driver_opts:
# type: ext4
# o: bind
# device: "/home/deepin/Applications/hedgedoc-container/uploads"

volumes:
database:
uploads:

secrets:
# source of all docker secrets
dbuser:
file: ./dbuser.txt
dbpassword:
file: ./dbpassword.txt
dbrootpassword:
file: dbrootpassword.txt
dbURL:
file: ./dbURL.txt
在服务端防火墙中开启http服务和88端口

如果买了大厂ECS服务器,请在提供商网站内更改安全组,开启88端口。(一般默认开启http服务)

如果是本地服务器

centos主机开启http服务和88端口:
1
2
3
4
5
6
# 针对外开启http服务
sudo firewall-cmd --zone=public --add-service=http --permanent
# 对外开放88端口
sudo firewall-cmd --zone=public --add-port=88/tcp --permanent
# 重新加载firewall规则
sudo firewall-cmd --reload

查看是否开启成功:

1
2
sudo firewall-cmd --zone=public --list-services #正确结果包含http
sudo firewall-cmd --zone=public --list-ports # 正确结果出现88/tcp
Ubuntu开启端口(默认http等服务已开启)
1
sudo ufw allow 88
访问< your domain:88 >,可以看到HedgeDoc页面(与https://demo.hedgedoc.org/相同)

HedgeDoc页面