用Docker在Ubuntu 18.04上构建GROWI
概括
以前,我在CentOS上公开了使用Docker构建GROWI的步骤,但现在我也整理了在Ubuntu上构建的方法。
在CentOS中构建GROWI的步骤 ↓
使用Docker构建GROWI
环境
在ESXi 6.7上创建Ubuntu 18.04虚拟机,并在其上进行搭建。
更新软件包
sudo apt update
sudo apt upgrade
Docker的安装
1. 更新存储库
- パッケージをインストールする
sudo apt install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
- DockerのGPG keyを追加する
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- Repository( stable ) を追加する
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
- パッケージのupdateを実施する
sudo apt update
安装docker
- インストールする
sudo apt install -y docker-ce
- dockerの起動確認を行う
$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: e
Active: active (running) since Sat 2020-03-21 12:25:35 JST; 28min ago
Docs: https://docs.docker.com
Main PID: 28276 (dockerd)
Tasks: 31
CGroup: /system.slice/docker.service
tq 3549 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port
tq 3603 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port
mq28276 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/contai
3. 使得普通用户无需使用sudo就可以使用docker。
- 一般ユーザをDocker groupに追加する
进行对「※的部分」进行更改。这时不需要使用「<,>」。
sudo gpasswd -a <yourusername> docker
- dockerが使用するソケットを一般ユーザでも読み込み出来るようにする
sudo chmod 666 /var/run/docker.sock
安装Docker Compose
-
- 最新のバージョンを確認
docker-composeのリリースノート
下記コマンドでダウンロード
export compose='1.25.1'
- /usr/local/bin/ 配下にダウンロード
sudo curl -L https://github.com/docker/compose/releases/download/${compose}/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
- 実行権限の付与
sudo chmod 0755 /usr/local/bin/docker-compose
- versionの確認
$ docker-compose -v
docker-compose version 1.25.1, build a82fef07
安装Git
- すでにインストール済みの場合もあるが一応...
sudo apt install git
GROWI的构建
由于准备工作已经完成,现在我们可以开始安装Growi了。
复制GROWI
这次我们将在/opt目录下进行构建。
# cd /opt
# sudo git clone https://github.com/weseek/growi-docker-compose.git growi
# cd growi
2. 编辑docker-compose.yml文件
接下来,我们将编辑docker-compose.yml文件。
-
- サーバの外からもアクセスしたいので127.0.0.1は削除する
-
- 「FILE_UPLOAD=local」はコメントアウトを外すことでローカル(Docker内)に画像が保存できる
- 「elasticsearch:」の”ES_JAVA_OPTS=-Xms256m -Xmx256m”は”ES_JAVA_OPTS=-Xms512m -Xmx512m”にしておき,メモリに余裕がある場合は”ES_JAVA_OPTS=-Xms2g -Xmx2g”にしておいた方が良い.(メモリを少なく設定するとElasticsearchが起動しないことがある)
version: '3'
services:
app:
build:
context: .
dockerfile: ./Dockerfile
ports:
# - 127.0.0.1:3000:3000 # localhost only by default
- 3000:3000 # localhost only by default
links:
- mongo:mongo
- elasticsearch:elasticsearch
depends_on:
- mongo
- elasticsearch
environment:
- MONGO_URI=mongodb://mongo:27017/growi
- ELASTICSEARCH_URI=http://elasticsearch:9200/growi
- PASSWORD_SEED=changeme
# - FILE_UPLOAD=mongodb # activate this line if you use MongoDB GridFS rather than AWS
# - FILE_UPLOAD=local # activate this line if you use local storage of server rather than AWS
# - MATHJAX=1 # activate this line if you want to use MathJax
# - PLANTUML_URI=http:// # activate this line and specify if you use your own PlantUML server rather than public plantuml.com
# - HACKMD_URI=http:// # activate this line and specify HackMD server URI which can be accessed from GROWI client browsers
# - HACKMD_URI_FOR_SERVER=http://hackmd:3000 # activate this line and specify HackMD server URI which can be accessed from this server container
# - FORCE_WIKI_MODE='public' # activate this line to force wiki public mode
# - FORCE_WIKI_MODE='private' # activate this line to force wiki private mode
command: "dockerize
-wait tcp://mongo:27017
-wait tcp://elasticsearch:9200
-timeout 60s
npm run server:prod"
restart: unless-stopped
volumes:
- growi_data:/data
mongo:
image: mongo:3.6
restart: unless-stopped
volumes:
- mongo_configdb:/data/configdb
- mongo_db:/data/db
elasticsearch:
build:
context: ./elasticsearch
dockerfile: ./Dockerfile
environment:
- bootstrap.memory_lock=true
# - "ES_JAVA_OPTS=-Xms256m -Xmx256m" # increase amount if you have enough memory
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" # increase amount if you have enough memory
ulimits:
memlock:
soft: -1
hard: -1
restart: unless-stopped
volumes:
- es_data:/usr/share/elasticsearch/data
- ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
volumes:
growi_data:
mongo_configdb:
mongo_db:
es_data:
当编辑完成后,请保存。
3. 启动
一旦到这里,只需要启动了。
# docker-compose up
开机后 (Qǐ
直到动作稳定之前需要一些时间。
当访问http://{服务器IP}:3000/时,将显示初始界面,请输入用户信息。
在这里注册的用户将自动被授予管理权限。

故障排除
CodiMD協作(選項)
在上述的内容中,GROWI可以使用。现在我们将与CodiMD合作,实现多人同时编辑的功能。关于功能的介绍,请查看GROWI的文档。
将docker-compose.override.yml文件复制到与docker-compose.yml文件相同的层级中。
- 作業前にGROWIが起動している場合はdocker-compose stopでアプリケーションを停止させます.
在使用Docker安装GROWI后,在GROWI文件夹内会有一个名为”examples”的文件夹,该文件夹中包含一个名为”integrate-with-hackmd”的文件夹,其中有一个名为”docker-compose.override.yml”的文件。将该文件复制到与docker-compose.yml文件相同的层级。
# sudo cp /opt/growi/examples/integrate-with-hackmd/docker-compose.override.yml /opt/growi/
编辑docker-compose.override.yml文件
-
- 「GROWI_URI」はブラウザでGROWIにアクセスするURLを入力します.例:http://{サーバのIP}:3000
- サーバ以外で使用したいので172.0.0.1は削除します.
version: '3'
services:
##
# HackMD(CodiMD) container
# see https://github.com/hackmdio/codimd#configuration
#
hackmd:
build:
context: ./hackmd
environment:
- GROWI_URI=http://192.168.0.101:3000
- CMD_DB_URL=mysql://hackmd:hackmdpass@mariadb:3306/hackmd
- CMD_CSP_ENABLE=false
ports:
# - 172.0.0.1:3100:3000 # localhost only by default
- 3100:3000 # localhost only by default
depends_on:
- mariadb
restart: unless-stopped
##
# MariaDB
# see https://hub.docker.com/_/mariadb/
mariadb:
image: mariadb:10.3
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
environment:
- MYSQL_USER=hackmd
- MYSQL_PASSWORD=hackmdpass
- MYSQL_DATABASE=hackmd
- MYSQL_RANDOM_ROOT_PASSWORD=true
restart: unless-stopped
volumes:
- mariadb_data:/var/lib/mysql
volumes:
mariadb_data:
编辑完成后,保存文件。
编辑docker-compose.yml文件。
-
- 「HACKMD_URI」と「HACKMD_URI_FOR_SERVER」のコメントアウトを外す
- 「HACKMD_URI」にはブラウザでCodiMDにアクセスするURLを入力します.例:http://{サーバのIP}:3100
version: '3'
services:
app:
build:
context: .
dockerfile: ./Dockerfile
ports:
- 3000:3000 # localhost only by default
links:
- mongo:mongo
- elasticsearch:elasticsearch
depends_on:
- mongo
- elasticsearch
environment:
- MONGO_URI=mongodb://mongo:27017/growi
- ELASTICSEARCH_URI=http://elasticsearch:9200/growi
- PASSWORD_SEED=changeme
# - FILE_UPLOAD=mongodb # activate this line if you use MongoDB GridFS rather than AWS
# - FILE_UPLOAD=local # activate this line if you use local storage of server rather than AWS
# - MATHJAX=1 # activate this line if you want to use MathJax
# - PLANTUML_URI=http:// # activate this line and specify if you use your own PlantUML server rather than public plantuml.com
- HACKMD_URI=http://192.168.0.101:3100 # activate this line and specify HackMD server URI which can be accessed from GROWI client browsers
# - HACKMD_URI_FOR_SERVER=http://hackmd:3000 # activate this line and specify HackMD server URI which can be accessed from this server container
# - FORCE_WIKI_MODE='public' # activate this line to force wiki public mode
# - FORCE_WIKI_MODE='private' # activate this line to force wiki private mode
command: "dockerize
-wait tcp://mongo:27017
-wait tcp://elasticsearch:9200
-timeout 60s
npm run server:prod"
restart: unless-stopped
volumes:
- growi_data:/data
mongo:
image: mongo:3.6
restart: unless-stopped
volumes:
- mongo_configdb:/data/configdb
- mongo_db:/data/db
elasticsearch:
build:
context: ./elasticsearch
dockerfile: ./Dockerfile
environment:
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" # increase amount if you have enough memory
ulimits:
memlock:
soft: -1
hard: -1
restart: unless-stopped
volumes:
- es_data:/usr/share/elasticsearch/data
- ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
volumes:
growi_data:
mongo_configdb:
mongo_db:
es_data:
编辑完成后进行保存。
4. 开启
如果到达这一步,就像GROWI一样启动。
# docker-compose up
CodiMD会自动安装并启动。
- CodiMDには1GBほどのメモリを消費するため,elasticsearchに割り当てたメモリによっては起動しないことがあるため注意
5. 網站URL的設置。

在「数据库」的选项中,输入刚刚在docker-compose.override.yml中通过GROWI_URI设置的地址,然后点击「更新」。
6. 用法
- 「HackMD」をクリックする

- Start to edit with HackMDをクリックする

- 下記のような画面が表示されればOK

请注意
只有在新建页面的情况下,先在GROWI的编辑器中输入内容并创建页面,然后才能切换到HackMD模式进行编辑。
选项栏
现在的4.0.0版本及以上不再运行。
-
- GROWIに正式に実装されているわけではないが以下のページを参考にさせていただき,Sidebarを実装しました.
- 管理 > カスタマイズ > カスタムスクリプトに以下のコードを記載することでSidebarが使用できます.
// sidebarのリンク
var links = [
["/sample1", "sample 1"],
["/sample2", "sample 2"],
["/admin/customize", "(customize this)"],
]
/*
sidebarにリンク作る
*/
var sidemenu = document.querySelector('#side-menu');
if (sidemenu) {
var li = function(href, name){
return '<li class="tbd"><a href="' + href + '">' + name + '</a></li>'
}
innerHTML = ""
for (var i=0; i<links.length; i++){
innerHTML += li(links[i][0], links[i][1])
}
sidemenu.innerHTML = innerHTML;
}
总结
我在Ubuntu上成功地搭建了GROWI。
请在中国本土参考一下。
Docker安装相关
在Ubuntu 18.04上安装Docker(包括docker-compose)。
安装Git
在Ubuntu上安装Git
安装growi
使用Docker构建GROWI(与CodiMD连接)的文档。