安装docker

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
#官方网站https://docs.docker.com/engine/install/ubuntu/
# Uninstall old versions
sudo apt-get remove docker docker-engine docker.io containerd runc
#Update the apt package index and install packages to allow apt to use a repository over HTTPS
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
#Add Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.
sudo apt-key fingerprint 0EBFCD88
####会出现
pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) <[email protected]>
sub rsa4096 2017-02-22 [S]
####end
#To add the nightly or test repository
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
#INSTALL DOCKER ENGINE
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
#test
sudo docker run hello-world

配置阿里源

1
2
3
4
5
6
7
8
9
#官方网址https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors?spm=5176.12901015.0.i12901015.76b5525c94CVTc
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://7qewi63s.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

安装docker-compose

1
2
3
4
5
#官方文档https://docs.docker.com/compose/install/
pip install docker-compose
#可能要用软链接,连接到/usr/local/bin
#test
docker-compose --version

拉取镜像并配置

1
2
3
4
5
6
7
8
# 拉取
docker pull sharelatex/sharelatex
# 建立用户文件夹
mkdir ~/Docker && cd ~/Docker
mkdir sharelatex && cd sharelatex
# 下载docker配置文件
wget https://raw.githubusercontent.com/sharelatex/sharelatex/master/docker-compose.yml

修改配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
sharelatex:
ports:
- 50000:80 # 不常用端口
volumes:
- ~/Docker/sharelatex_data:/var/lib/sharelatex
environment: # 加入2020版texlive到PATH
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/texlive/2020/bin/x86_64-linux/:/usr/local/texlive/2019/bin/x86_64-linux/
mongo:
volumes:
- ~/Docker/mongo_data:/data/db
redis:
volumes:
- ~/Docker/redis_data:/data

创建Docker容器

1
docker-compose up -d

安装升级完整texlive

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 进入容器
docker exec -it sharelatex bash
cd /usr/local/texlive

#参考官网升级教程:https://www.tug.org/texlive/upgrade.html
cp -a 2019 2020
wget http://mirror.ctan.org/systems/texlive/tlnet/update-tlmgr-latest.sh
sh update-tlmgr-latest.sh -- --upgrade
# 国内同学请切换清华源
tlmgr option repository https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet/
# 耗时略长
tlmgr update --self --all
luaotfload-tool -fu
# 耗时极长,建议考虑screen命令,防止断开
tlmgr install scheme-full
exit

配置用户

1
2
# 重启
docker restart sharelatex

打开浏览器访问http://hostname:5000/launchpad,创建Admin账户

文章参考:

https://www.bilibili.com/read/cv6547551/

[http://blog.codedo.cn/2020/04/16/Set Overleaf server/](http://blog.codedo.cn/2020/04/16/Set Overleaf server/)

激活邮箱服务和SSL证书:https://www.scaleway.com/en/docs/installing-sharelatex-ubuntu/