CoRfr / spex-3gpp

A WebService to deliver 3GPP specifications.
GNU General Public License v3.0
34 stars 17 forks source link

Container usage #2

Closed mrlnc closed 4 years ago

mrlnc commented 4 years ago

I'm using this issue to document my setup. Just running docker run --name spex -p 80:80 corfr/spex didn't work for me, e.g., the production environment requires a mysql host in place.

Docker Setup

The docker image is available as corfr/spex or from sources:

host:spex$ docker build -t spex .

Spex stores all downloaded content on disk, and maintains an index in a mysql database. First, set up the mysql server:

host:~$ docker network create spex-net
host:~$ docker run --name spex-mysql --network spex-net -e MYSQL_ROOT_PASSWORD=spex -d mysql:latest

Connect to the mysql machine and create a database:

host:~$ docker run -it --network spex-net --rm mysql mysql -hspex-mysql -uroot -p
# (mysql is automatically started)
mysql> CREATE DATABASE spex;

Now we can start spex and point it to the MySQL database.

host:~$ docker run --name spex --network spex-net -e MYSQL_ENV_DB_NAME=spex -e MYSQL_ENV_DB_USER=root -e MYSQL_ENV_DB_PASS=spex -e MYSQL_PORT_3306_TCP_ADDR=spex-mysql -p 3000:80 corfr/spex

On first run, you'll need to manually populate the database:

host:~$ docker exec -ti spex bash
spex:~$ cd /home/app/webapp
spex:webapp$ bundle exec rake db:setup
# if the database cannot be manipulated, first disable the security checks and re-execute above command
spex:webapp$ export DISABLE_DATABASE_ENVIRONMENT_CHECK=1

The spex website is now available on http://localhost:3000

mrlnc commented 4 years ago

Merged PR #4