2021年3月30日星期二

使用 Docker 镜像安装 Radicale

1. 安装 Docker 环境

2. 下载 Radicale 镜像
```
docker pull cnkmmk/radicale:3.0.6-r0
```

3. 配置文件的准备

一共3个配置文件,config, users, rights
users 为用户帐号记录,我使用的是MD5,生成可以直接使用 htpasswd 在线工具 [https://tool.oschina.net/htpasswd](https://tool.oschina.net/htpasswd),一个用户一行,格式为:username:password

```
mkdir -p /home/radicale/etc /home/radicale/collections

echo 'username:$apr1$OcPL.lFw$KBVFjrNTksW0exp5TeKjj.' > /home/radicale/etc/users

cat << EOF > /home/radicale/etc/config
[server]
hosts = 0.0.0.0:5232

[encoding]
request = utf-8
stock = utf-8

[auth]
type = htpasswd
htpasswd_filename = /etc/radicale/users
htpasswd_encryption = md5

[rights]
type = from_file
file = /etc/radicale/rights

[storage]
filesystem_folder = /var/lib/radicale/collections
EOF

cat << EOF > /home/radicale/etc/rights
[root]
user: .+
collection:
permissions: R

[principal]
user: .+
collection: {user}
permissions: RW

[calendars]
user: .+
collection: {user}/[^/]+
permissions: rw
EOF
```

4. 启动容器
```
docker run -itd -v /home/radicale/etc:/etc/radicale -v /home/radicale/collections:/var/lib/radicale/collections -p 5232:5232  cnkmmk/radicale:3.0.6-r0
```