Skip to content

Latest commit

 

History

History
105 lines (66 loc) · 4.46 KB

INSTALL-DOCKER.md

File metadata and controls

105 lines (66 loc) · 4.46 KB

Running Trustroots with Docker

Trustroots Docker containers are excellent for getting into development quickly.

Development with Docker might be little bit slower than running Mongo+NodeJS+NPM directly at your computer, but saves you from installing and configuring all the required dependencies.

Note that we are not keeping too close eye on Docker setup so things might break unexpectedly. Feel free to help us maintain the docker setup!

Prerequisites

  • Install Docker on your system.
  • Install Docker Compose on your system.
  • Make sure you have git installed on your system (git --version, preinstalled on OSX)

Install

1. Clone the repository
git clone https://github.com/Trustroots/trustroots.git
cd trustroots
2. Create a config file

This will do:

cp config/env/local.docker.js config/env/local.js

Optional: See config/env/local.sample.js or config/env/default.js for details if you want to change something.

3. Run the install script
docker-compose up

This will take a while. Good news is you just have to sit back and let it do it's magic.

4. Done!

You can now access these from your browser:

Running & development

  • Hit Ctrl+C to turn off containers.
  • Type docker-compose up to start them up again.
  • You might want to run containers as daemon: docker-compose up -d and then read the logs only from "trustroots" container: docker-compose logs trustroots. You can use a helper script: ./scripts/docker/up.sh
  • If you see a lot of Run migrate DB script on update coming from Nginx container, it means NodeJS isn't up yet or it has stopped due error. You should see "Trustroots server is up and running now." once Trustroots is really running.
  • Type docker-compose build --no-cache trustroots to rebuild them to have fresh install.
  • When you do changes to any files, they get recompiled and the browser is refreshed. If this step feels too slow for your needs, it's because of Docker. This step is faster on local install so you might want to consider that.
  • Keep an eye on console in case of compiling errors.
  • To read and debug emails, open Maildev http://localhost:1080 in your browser. Mails won't leave your Docker container unless you configure mailer settings from config/env/local.js to use e.g. SparkPost or Gmail.
  • To read and debug MongoDB use e.g. Robomongo to connect to localhost on port 27017.
  • To run any npm script root folder, just run docker-compose run trustroots npm COMMAND_NAME. App is installed to /trustroots folder inside the container but working directory is set so that any commands default to that folder.
  • Read more

Mock data

There's a script that can generate mock user data. It's recommended you run this script after installation, that way you'll have something to look at.

  1. Run docker-compose run trustroots node scripts/fillTestData.js 10000 adminusername — that will create 10000 users and hosting offers. adminusername is optional (a-z0-9) and will create an admin user.
  2. It can take up to 5 minutes. Mongoose might complain about duplicates — just ignore these errors.
  3. To see the result, log in with your chosen username and password password123.

Clean database

To drop your database, run:

docker-compose run trustroots npm run dropdb

Upgrading

git pull
docker-compose run trustroots npm update

Running tests

  • docker-compose run trustroots npm test (both client & server)
  • docker-compose run trustroots npm run test:client
  • docker-compose run trustroots npm run test:client:watch (run + watch for changes)
  • docker-compose run trustroots npm run test:server
  • docker-compose run trustroots npm run test:server:watch (run + watch for changes)

Problems