..

自建asciinema服务器

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

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

cp .env.production.sample .env.production

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

docker-compose up -d postgres

创建数据库表结构

docker-compose run --rm phoenix setup

启动容器

docker-compose up -d

检查容器状态

docker ps -f 'name=asciinema_'

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

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

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