Merge pull request #248 from asciinema/install-doc

Install doc
revealjs
Marcin Kulik 7 years ago committed by GitHub
commit e2e4f2d66b

@ -1,4 +1,5 @@
.git
.gitignore
.stuff
.bundle
tmp/*
@ -6,6 +7,7 @@ log/*
target
uploads/*
coverage
volumes
Dockerfile
docker-compose.yml
a2png/main.js
@ -16,4 +18,4 @@ a2png/target
config/asciinema.yml
config/database.yml
.env
.env.*
.env.*

2
.gitignore vendored

@ -37,3 +37,5 @@ pom.xml.asc
/profiles.clj
/dev/resources/local.edn
/dev/src/local.clj
/volumes

@ -1,22 +1,12 @@
version: '2'
# Quickstart:
# docker-compose run --rm db_init
# docker-compose up -d web
# To cleanup:
# docker-compose stop && docker-compose rm
services:
postgres:
image: postgres
container_name: asciinema_postgres
restart: unless-stopped
### Uncomment to enable DB persistence
# volumes:
# - ./postgres:/var/lib/postgresql/data
volumes:
- ./volumes/postgres:/var/lib/postgresql/data
### See https://hub.docker.com/_/postgres/ for more
### configuration options for this image.
@ -24,11 +14,8 @@ services:
image: redis
container_name: asciinema_redis
restart: unless-stopped
### Uncomment to enable Redis persistence
# volumes:
# - ./redis:/data
volumes:
- ./volumes/redis:/data
### See https://hub.docker.com/_/redis/ for more
### configuration options for this image.
@ -44,14 +31,14 @@ services:
env_file: .env.production
command: "bundle exec sidekiq"
volumes:
- /tmp/asciinema/uploads:/app/uploads
- ./uploads:/app/uploads
- ./log:/app/log
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.
@ -70,15 +57,5 @@ services:
ports:
- "3000:80"
volumes:
- /tmp/asciinema/uploads:/app/uploads
db_init:
build: .
image: asciinema/asciinema.org
links:
- redis
- postgres
env_file: .env.production
command: "bundle exec rake db:setup"
volumes:
- /tmp/asciinema/uploads:/app/uploads
- ./uploads:/app/uploads
- ./log:/app/log

@ -1,86 +1,140 @@
# asciinema web app install guide
## Quickstart Using Docker Compose
The only officially supported installation procedure of asciinema web app
is [Docker](https://www.docker.com/) based. You must have SSH access to a
64-bit Linux server with Docker support.
Required:
If you really, really want to install everything manually then look
at [Dockerfile](../Dockerfile) and [docker-compose.yml](../docker-compose.yml)
to see what's required by the app.
- [Docker](https://docs.docker.com/engine/getstarted/step_one/#step-1-get-docker)
- [docker-compose 1.5+](https://docs.docker.com/compose/install/)
## Hmm, why Docker?
```bash
$ wget https://raw.githubusercontent.com/asciinema/asciinema.org/master/docker-compose.yml
$ docker-compose run --rm db_init
$ docker-compose up -d web
Hosting non-trivial web applications is complicated. Setting this one up
requires installation of fair number of system packages and build tools,
configuring monitoring of several processes, as well as configuring Nginx. Also,
you need PostgreSQL, Redis, and SMTP server.
```
With Docker, you get the battle tested configuration (similar to what's running
on asciinema.org), in a stable container, along with all required services
preconfigured.
You can override the address/port that is sent in email with login token by passing HOST="host:port" environment variable when starting the web server.
It also makes upgrading to new versions much easier.
Assuming you are running Docker Toolbox and VirtualBox: go to http://your-docker-host:3000/ and enjoy.
## Hardware Requirements
## Manual setup
- modern single core CPU, dual core recommended
- 1 GB RAM minimum (with swap)
- 64 bit Linux compatible with Docker
- 10 GB disk space minimum
### 1. Install dependencies
## Service Requirements
asciinema.org site is a Ruby on Rails application. You need to have following
dependencies installed:
asciinema web app requires the following services:
* Ruby 2.0+ (Ruby 2.1 is recommended)
- [Postgres 9.5+](http://www.postgresql.org/download/)
- [Redis 2.6+](http://redis.io/download)
- SMTP server
* bundler gem
`gem install bundler`
If you go with the provided [docker-compose.yml](../docker-compose.yml) file you
don't need to worry about these - they're included and already configured to
work with this app.
* PostgreSQL 8+ with libpq development headers
`sudo apt-get install postgresql libpq-dev` on Debian/Ubuntu
## Installation
* asciinema's libtsm fork (`asciinema` branch)
See [here](https://github.com/asciinema/libtsm/blob/asciinema/README) for installation instructions.
If you don't install it now the setup script (point 4 below) will try to
install it for you anyway.
This guide assumes you already
have [Docker engine](https://docs.docker.com/engine/)
and [docker-compose](https://docs.docker.com/compose/) running on the
installation host.
* phantomjs 2.0+
`sudo add-apt-repository ppa:tanguy-patte/phantomjs && sudo apt-get update && sudo apt-get install phantomjs`
You don't have to use docker-compose to use asciinema web app Docker image. Feel
free to inspect `docker-compose.yml` file and run required services manually with
`docker run ...`. However, for the sake of simplicity and to miminize
configuration issues the rest of this guide is based on the provided/suggested
docker-compose configuration.
### 2. Get the source code
### Clone the repository
Clone git repository:
git clone --recursive https://github.com/asciinema/asciinema.org.git
```bash
$ git clone git://github.com/asciinema/asciinema.org.git
$ cd asciinema.org
```
### Edit config file
### 3. Prepare database config file
You need to create `.env.production` config file. The easiest is to use
provided [.env.production.sample](../.env.production.sample) as a template:
Copy *config/database.yml.example* to *config/database.yml*. Then set
database/user/password to whatever you prefer.
cp .env.production.sample .env.production
nano .env.production
If database specified in database.yml doesn't exist then the following setup
task will create it (make sure database user is allowed to create new
databases).
There are several variables which have to be set, like `BASE_URL` and
`SECRET_KEY_BASE`. The rest is optional, and most likely used when you want to
use your own SMTP, PostgreSQL or Redis server.
### 4. Setup the app
#### Basic settings
Following script will install gem dependencies and setup database:
Set `BASE_URL` to the URL your users are supposed to reach this instance at.
Example: `http://asciinema.example.com`.
```bash
$ ./script/setup
```
Set `SECRET_KEY_BASE` to long random string. Run `docker-compose run --rm web
bundle exec rake secret` to obtain one.
### 5. Run Rails server
#### SMTP settings
```bash
$ bundle exec rails server
```
The app uses linked `namshi/smtp` container, which by default runs in "SMTP
Server" mode. Set `MAILNAME` to the outgoing mail hostname, for example, use the
same hostname as in `BASE_URL`.
### 6. Run the background job processor
You can configure it to act as GMail relay, Amazon SES relay or generic SMTP
relay. See
[namshi/docker-smtp README](https://github.com/namshi/docker-smtp/blob/master/README.md)
for details.
The background job processor is needed for asciicast pre-processing and
thumbnail generation.
For example, to send emails through GMail add `GMAIL_USER` and `GMAIL_PASSWORD`
(most likely
[App Password](https://support.google.com/accounts/answer/185833?hl=en))
variables to the config file.
```bash
$ bundle exec sidekiq
```
#### Database settings
`DATABASE_URL` and `REDIS_URL` point to linked `postgres` and `redis` containers
by default. You can set these so they point to your existing services. Look at
"Service Requirements" above for minimum versions supported.
### Specify volume mappings
The container has two volumes, for user uploads and for application logs. The
default `docker-compose.yml` maps them to the repository's `uploads` and `log`
directories, you may wish to put them somewhere else.
Likewise, the PostgreSQL and Redis images have data volumes that you may wish to
map somewhere where you know how to find them and back them up. By default
they're mapped inside repository's `volumes` directory.
### Initialize the database
You have the config file ready and the data volumes mapped. It's time to set up
the database.
Start PostgreSQL container (skip this if you use existing PostgreSQL server):
docker-compose up -d postgres
Create database schema and seed it with initial data:
docker-compose run --rm web bundle exec rake db:setup
### Create containers
The final step is to create the containers:
docker-compose up -d
Check the status of newly created containers:
docker ps -f 'name=asciinema_'
You should see `asciinema_web`, `asciinema_postgres` and a few others listed.
Point your browser to `BASE_URL` and enjoy your own asciinema hosting site!
## Using asciinema recorder with your instance

Loading…
Cancel
Save