atuin/docs/zh-CN/docker.md
Bruce Huang 02049bf68d
update zh-CN docs (#539)
* update zh-CN docs

* update zh-CN docs

* update zh-CN docs

* update zh-CN docs
2022-10-08 03:36:49 +00:00

90 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Docker
Atuin 提供了一个 docker 镜像image可以更轻松地将服务器部署为容器container
```sh
docker run -d -v "$USER/.config/atuin:/config" ghcr.io/ellie/atuin:latest server start
```
# Docker Compose
使用已有的 docker 镜像image来托管你自己的 Atuin可以使用提供的 docker-compose 文件来完成
在 docker-compose.yml 同级目录下创建一个 .env 文件,内容如下:
```
ATUIN_DB_USERNAME=atuin
# 填写你的密码
ATUIN_DB_PASSWORD=really-insecure
```
创建 `docker-compose.yml` 文件:
```yaml
version: '3.5'
services:
atuin:
restart: always
image: ghcr.io/ellie/atuin:main
command: server start
volumes:
- "./config:/config"
links:
- postgresql:db
ports:
- 8888:8888
environment:
ATUIN_HOST: "0.0.0.0"
ATUIN_OPEN_REGISTRATION: "true"
ATUIN_DB_URI: postgres://$ATUIN_DB_USERNAME:$ATUIN_DB_PASSWORD@db/atuin
postgresql:
image: postgres:14
restart: unless-stopped
volumes: # 不要删除索引数据库文件的永久存储空间!
- "./database:/var/lib/postgresql/data/"
environment:
POSTGRES_USER: $ATUIN_DB_USERNAME
POSTGRES_PASSWORD: $ATUIN_DB_PASSWORD
POSTGRES_DB: atuin
```
使用 `docker-compose` 启动服务:
```sh
docker-compose up -d
```
## 使用 systemd 管理你的 atuin 服务器
以下 `systemd` 的配置文件用来管理你的 `docker-compose` 托管服务:
```
[Unit]
Description=Docker Compose Atuin Service
Requires=docker.service
After=docker.service
[Service]
# Where the docker-compose file is located
WorkingDirectory=/srv/atuin-server
ExecStart=/usr/bin/docker-compose up
ExecStop=/usr/bin/docker-compose down
TimeoutStartSec=0
Restart=on-failure
StartLimitBurst=3
[Install]
WantedBy=multi-user.target
```
启用服务:
```sh
systemctl enable --now atuin
```
检查服务是否正常运行:
```sh
systemctl status atuin
```