自建asciinema服务器

把自己的终端上传到官方服务器,始终是一件不安全的事情,所以推荐大家自建asciinema服务器。直接使用官方的docker-compose文件,稍加修改就能成功clone官方的项目

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
version: '2'

services:
postgres:
image: postgres
container_name: asciinema_postgres
restart: unless-stopped
volumes:
- ./volumes/postgres:/var/lib/postgresql/data
### See https://hub.docker.com/_/postgres/ for more
### configuration options for this image.

redis:
image: redis
container_name: asciinema_redis
restart: unless-stopped
volumes:
- ./volumes/redis:/data
### See https://hub.docker.com/_/redis/ for more
### configuration options for this image.

smtp:
image: namshi/smtp
container_name: asciinema_smtp
restart: unless-stopped
env_file: .env.production
### See https://github.com/namshi/docker-smtp for more SMTP configuration
### options for this image.

nginx:
image: nginx:alpine
container_name: asciinema_nginx
restart: unless-stopped
links:
- phoenix
- rails
ports:
- "3000:80"
### Uncomment for HTTPS:
# - "443:443"
volumes:
- ./docker/nginx/asciinema.conf:/etc/nginx/conf.d/default.conf:ro
- ./volumes/cache:/cache
### Uncomment for HTTPS (make sure to add your cert and private key to ./certs):
# - ./certs:/app/priv/certs
### See https://hub.docker.com/_/nginx/ for more configuration options for
### this image.

phoenix:
build: .
image: asciinema/asciinema-server:latest
command: mix phx.server
container_name: asciinema_phoenix
restart: unless-stopped
links:
- redis
- postgres
- smtp
env_file: .env.production
### Uncomment for access to ExqUI (for debugging):
# ports:
# - "4040:4040"
volumes:
- ./uploads:/app/uploads
- /tmp/asciinema-web:/tmp

rails:
build: .
image: asciinema/asciinema-server:latest
command: bundle exec unicorn -c config/unicorn.rb
container_name: asciinema_rails
restart: unless-stopped
links:
- redis
- postgres
env_file: .env.production
volumes:
- ./uploads:/app/uploads
- ./log:/app/log
- /tmp/asciinema-web:/tmp
- ./volumes/tmp:/app/tmp

这里需要一个外部文件.env.production

1
cp .env.production.sample .env.production

如果已经有了postgresql数据库可以跳过西面这条命令

1
docker-compose up -d postgres

创建数据库表结构

1
docker-compose run --rm phoenix setup

启动容器

1
docker-compose up -d

检查容器状态

1
docker ps -f 'name=asciinema_'

最后修改asciinema的客户端配置文件$HOME/.config/asciinema/config

1
2
[api]
url = https://your.asciinema.host

注意:第一使用asciinema不要直接修改配置文件,需要先使用一次asciinema上传一次到官方服务器,然后再修改配置文件。