Setup - Lokiedu/libertysoil-site GitHub Wiki
LibertySoil Setup
Currently there's more than one way to get the application up and running locally for development:
Docker
This project uses Docker Compose as primary means of setting up a development environment as well as for deployment.
Requirements
In order to get things rolling make sure to have at least Docker 1.8 installed (official Docker installation guide) and run these commands to set up Docker Compose (version 1.4.2):
$ sudo su -c "curl -L https://github.com/docker/compose/releases/download/1.4.2/docker-compose-`uname -s`-`uname -m` > /usr/bin/docker-compose"
...
$ chmod +x /usr/bin/docker-compose
Docker containers initiated by Docker Compose:
- NginX Proxy
- LibertySoil master application
- Redis memory cache container
- PostgreSQL DB container
Running
Once you have Docker Engine
and Docker Compose
installed, clone the libertysoil-site
repository, navigate to the root of the repo in your terminal and run:
$ docker-compose --file docker-compose.yml up -d
What this will do is to retrieve all 4 docker containers, set them up, and initiate them.
Once the machine is up and running make sure to edit your hosts
file and add the following entry:
127.0.0.1 alpha.libertysoil.org
Now simply visit the aforementioned domain in your browser.
Notes
If you plan to use on your hosts
file a different domain from the one included in the docker-compose.yml
file, be sure to update the configuration accordingly by changing the line which reads:
- "VIRTUAL_HOST=alpha.libertysoil.org"
to:
- "VIRTUAL_HOST=[your.development.domain]"
(where [your.development.domain]
should be replaced by the domain you plan to use)
Be sure to try the previous specially if you get a 503 Service Temporarily Unavailable
error from NginX.
Debugging
If the application is giving you back-end problems you can access the logs for each of the different containers initiated by running Docker Compose.
To find out the name of a container run:
$ docker ps -a
You should get an output which looks like this:
CONTAINER ID IMAGE ... NAMES
13737edc4b16 jwilder/nginx-proxy ... current_web_1
2ccd07aa5ea0 quay.io/dipstudio/libertysoil:master ... current_app_1
1f958b28db64 redis:3.0 ... current_redis_1
bd3fbc2b613f postgres:9.4 ... current_db_1
once you have the container name (current_app_1
fore xample) simply run:
$ docker logs current_app_1
Vagrant
We have included a Vagrant container based off of VagrantEasy.
It runs Ubuntu 14.04 and installs everything necessary for the application to be run from within the container, but with access to the repository files from a shared folder on your host machine.
https://github.com/Lokiedu/libertysoil-vagrant
Requirements
In order to use the VagrantEasy container you must have installed:
In order to setup the application using the provided VagrantEasy container you have to clone both the libertysoil-site
and the libertysoil-vagrant
repositories to the same folder.
Running
Once you have cloned both the libertysoil-site
and the libertysoil-vagrant
repositories to the same folder, navigate to the libertysoil-vagrant
repo folder from the terminal and run:
$ vagrant up
Note: Depending on the available Vagrant images on your machine, this process might take a while to complete if Vagrant has to download the Ubuntu 14.04 image.
Now you can start an ssh session by running:
$ vagrant ssh
Once logged in, navigate to /var/www/libertysoil-site/current
folder and run:
$ sudo npm install -g babel babel-eslint eslint eslint-plugin-react gulp nodemon knex
...
$ npm install
Warning: If host machine is running Windows you must do a little extra setup for npm install
command to work correctly. Follow the instructions on this post to fix Vagrant in Windows issues: http://blog.prolificinteractive.com/2015/01/21/getting-vagrant-nodejs-windows-play-well-together/
Use gulp to build the assets (styles, fonts, etc):
$ gulp build
Before running the application make sure to create the appropriate user credentials for the app in PostgreSQL:
$ sudo apt-get install -y postgresql-9.4 postgresql-contrib-9.4 libpq-dev
$ sudo su - postgres
postgres@libertysoil:~$ createuser libertysoil
postgres@libertysoil:~$ psql
postgres=# ALTER ROLE libertysoil WITH SUPERUSER CREATEDB REPLICATION LOGIN;
postgres=# \password libertysoil
postgres=# CREATE DATABASE libertysoil;
postgres=# \q
postgres@libertysoil:~$ exit
Now run the LibertySoil application by issuing the command:
$ npm start
Note: This will also run migrations
Once the machine and app are up and running make sure to edit your hosts
file (in your host machine) and add the following entry:
192.168.12.19 libertysoil.dev
and visit the aforementioned url in the browser.
Notes
If you wish to use a different ip address and/or development domain, edit the pertinent configurations found within the config\development.yml
file and update your hosts
file accordingly.
If you change the config\development.yml
file while the Vagrant container is running, you must run:
$ vagrant destroy
...
$ vagrant up
You can power off the vagrant machine while not being used, to save resources, by running:
$ vagrant halt
You can suspend the machine, saving it's current state and freeing up resources, by running:
$ vagrant suspend
Local (Manual)
Requirements
- Redis 3.0
- Postgres 9.4
- NodeJS (4.2.1 is actively used by developers now)
Running
Before running the application make sure to create the appropriate user credentials for the app in PostgreSQL:
$ sudo su - postgres
postgres$ createuser libertysoil
postgres$ psql
postgres=# ALTER ROLE libertysoil WITH SUPERUSER CREATEDB REPLICATION LOGIN;
postgres=# \password libertysoil
postgres=# CREATE DATABASE libertysoil;
postgres=# \q
postgres@libertysoil:~$ exit
Navigate to libertysoil-site
root folder and install node dependencies by running:
$ sudo npm install -g babel babel-eslint eslint eslint-plugin-react gulp nodemon knex
...
$ npm install
Use gulp to build the assets (styles, fonts, etc):
$ gulp build
Now run the LibertySoil application by issuing the command:
$ npm start
App should now be available at http://localhost:8000