Install - HearstAT/ensemble GitHub Wiki
- Start by cloning this project
git clone https://github.com/HearstAT/ensemble.git
- Install Isolated (Preferred for Normal Dev, Shared Systems, and when utilizing rake setup commands)
bundle install --binstubs --path vendor/bundle
- Install to System
bundle install
- Note: Only recommended when installing to a system where ensemble will be the other app running (e.g.; Docker, AWS EC2)
- Install Options
- Assumptions:
- Commands are being run from the project directory unless otherwise stated
- Create a Compose File in the root of the project directory
- Filename:
docker-compose.yml
- Example if building image
version: '2'
services:
rails:
restart: always
build:
context: .
dockerfile: Dockerfile
args:
BUILD_ENV: production
ports:
- "3000:3000"
env_file:
- '.env'
- Example if pulling image
version: '2'
services:
rails:
restart: always
image: hearstat/ensemble
ports:
- "3000:3000"
env_file:
- '.env'
- Run the following commands
- Bring Up Server
- Non-Detached:
docker-compose up --build
- Detached (In Background):
docker-compose up --build -d
-
Note: add
-f $FILENAME.yml
before up in the commands above to use a differently filename fromdocker-compose.yml
- Non-Detached:
- Run DB Commands
docker-compose exec rails bundle exec rake db:create
docker-compose exec rails bundle exec rake db:migrate
- Bring Up Server
- Create a Compose File in the root of the project directory
- Filename:
docker-compose.yml
version: '2'
services:
rails:
restart: always
build:
context: .
dockerfile: Dockerfile
args:
BUILD_ENV: production
ports:
- "3000:3000"
- "1234:1234"
- "26162:26162"
env_file:
- '.env'
- Run the following commands
- Bring Up Server
- Non-Detached:
docker-compose up --build
- Detached (In Background):
docker-compose up --build -d
-
Note: add
-f $FILENAME.yml
before up in the commands above to use a differently filename fromdocker-compose.yml
- Non-Detached:
- Run DB Commands
docker-compose exec rails bundle exec rake db:create
docker-compose exec rails bundle exec rake db:migrate
docker-compose exec rails bundle exec rake db:seed
- Bring Up Server
- TODO
docker-compose -f dev-docker-compose.yml up --build
docker-compose exec website bundle exec rake db:create
docker-compose exec website bundle exec rake db:migrate
docker-compose exec website bundle exec bin/rake gather:pagerduty_incidents
Cleaning up:
docker-compose stop
docker-compose rm
- TODO
docker-compose -f dev-docker-compose.yml up --build
docker-compose exec website bundle exec rake db:create
docker-compose exec website bundle exec rake db:migrate
docker-compose exec website bundle exec bin/rake db:seed
Then navigate to http://localhost:3000 and login with the credentials from the db/seeds.rb file
Cleaning up:
docker-compose stop
docker-compose rm
- Database
- Create
bundle exec rake db:create
bundle exec rake db:migrate
- Seed:
- Create a BU and a PD account in the UI or follow here
bundle exec bin gather:pagerduty_incidents
- Create
- Start Ensemble
bundle exec rails s
- Database
- Create
bundle exec rake db:create
bundle exec rake db:migrate
- Seed:
- Either follow This Steps
- Or run this command:
bundle exec rake db:seed
- Create
- Start Ensemble
bundle exec rails s
However this falls out of date from time to time and will not have your email address/domain.
To create the first user you will need to use the rails console (like irb for rails) and create the first user. Note you will want to use an actual email address since it will send an email
Start console first via bundle exec rails c
Domain.create!(domain: 'example.com')
User.create!(email: '[email protected]', password: 'password', password_confirmation: 'password', admin: true)
Domain.create!(domain: 'example.com')
newuser = User.new(email: '[email protected]', password: 'password', password_confirmation: 'password', admin: true)
newuser.confirm
newuser.save!
TODO - Need to proof out these commands
PD.create!
We have created rake tasks to automate the bulk of the setup
These are the defaults for the rake command arguments below. There are some difference between the Local and Docker setups, but they are almost identical.
- ARG List:
- Local:
env vendor db_name db_user db_pass db_host db_pool db_port
- Vendor default is
true
- Vendor default is
- Docker:
env mount db_name db_user db_pass db_host db_port db_pool
- Mount default is
false
- Mount default is
- Local:
- Defaults:
env: 'prod'
db_name: 'railstest'
db_user: 'railstest1'
db_pass: 'railstest'
db_host: local_ip
db_port: 5432
db_pool: 10
- Calling rake task with all args looks like this
bundle exec rake setup:local['dev','true','railstest','railstest1','railstest','127.0.0.1','5432','10']
This command will automatically pull or build the Ensemble docker image to setup a full dockerized setup to run or test with
bundle exec rake install:docker
bundle exec rake install:docker['dev']
This command will automatically pull or build the Ensemble and Postgres docker images to setup a full dockerized setup to run or test with
bundle exec rake install:docker_ps
bundle exec rake install:docker_ps['dev']
Will install Ensemble locally and setup the database as needed
- Quick Run - Defaults
bundle exec rake install:local
- Development Quick Run
bundle exec rake install:local['dev]
Will install Ensemble locally and setup a sqlite database for testing
- Quick Run - Defaults
bundle exec rake install:local_ps
- Default List
bundle exec rake install:local_ps['dev']
There is an example of a cloudformation template in this repo here
Here are a few options to launch the stack via CLI.
- All Options
aws --region us-west-2 \
cloudformation create-stack \
--stack-name metrics-a \
--disable-rollback \
--template-body file://cloudformation/ensemble-single-instance.yml \
--parameters \
ParameterKey=HostedZone,ParameterValue=domain.com \
ParameterKey=SSLCertificateARN,ParameterValue=dfaf3c \
ParameterKey=MetricsSubdomain,ParameterValue=metrics-a \
ParameterKey=InstanceType,ParameterValue=t2.micro \
ParameterKey=KeyName,ParameterValue=arg3da \
ParameterKey=SSHSecurityGroup,ParameterValue=arg3da \
ParameterKey=CIDRA,ParameterValue=192.168.0.10 \
ParameterKey=CIDRB,ParameterValue=192.168.0.11 \
ParameterKey=DBSnapShot,ParameterValue=arg3da \ # Only use if restoring or building from DB snapshot
ParameterKey=DBUser,ParameterValue=arg3da \
ParameterKey=DBPassword,ParameterValue=arg3da \
ParameterKey=DBInstanceType,ParameterValue=db.t2.micro \
ParameterKey=DBPublic,ParameterValue=false \
ParameterKey=DBName,ParameterValue=railstest \ # Use only for Existing DB or Snapshot so correct name goes to config
ParameterKey=DBURL,ParameterValue=https://railsdb.domain.com # Only if existing DB is being used
- Limited w/ Defaults
aws --region us-west-2 \
cloudformation create-stack \
--stack-name metrics-a \
--disable-rollback \
--template-body file://cloudformation/ensemble-single-instance.yml \
--parameters \
ParameterKey=HostedZone,ParameterValue=domain.com \
ParameterKey=SSLCertificateARN,ParameterValue=arn:aws:acm: \
ParameterKey=MetricsSubdomain,ParameterValue=metrics-a \
ParameterKey=KeyName,ParameterValue=ssh_key_set_name \
ParameterKey=SSHSecurityGroup,ParameterValue=ssh_allow_group \
ParameterKey=CIDRA,ParameterValue=192.168.0.10 \
ParameterKey=CIDRB,ParameterValue=192.168.0.11 \
ParameterKey=DBUser,ParameterValue=railstest1 \
ParameterKey=DBPassword,ParameterValue=railstest