Docker for development
Written by Miguel Michelson
The easiest way to test and develop Chaskiq is using the dockerized container. So, in order to get that up and running, you will need to install Docker.
Before continue with the installation you must add some configs to your environment. The environment file is located at the root of the project in a .env file or if you have a .env.example rename it to .env
You have to set the HOST env variable, this is important in order for chaskiq to work on subdomain , but you can set localhost:3000 if you are not going to use helpcenter locally
HOST=http://app.chaskiq.test:3000 ASSET_HOST=http://app.chaskiq.test:3000 WS=ws://app.chaskiq.test/cable
Once you have installed Docker on your local environment you can run the build command in order to create the docker image instance.
docker-compose run rails rake db:create
Load database structure
docker-compose run rails rake db:schema:load
Seed the initial data
docker-compose run rails rake db:seed
Add a default admin for the forst application generated on the seeds step, check your .env file for ADMIN_EMAIL & ADMIN_PASSWORD env vars!
docker-compose run rails rake admin_generator
At this point you are ready to go to start the engines
docker-compose up rails
You can also run with docker-compose run --service-ports rails, in order to get the tty session, useful if you are going to use binding.pry or debugger on rails development
In a second terminal tab run this
docker-compose up webpacker
You may install the js dependences with yarn install, to do so run this command:
docker-compose run webpacker yarn install
in a third tab run this
docker-compose up sidekiq
To enter the machine to a bash session inside the project folder run:
docker-compose run runner
Note: docker-compose run runner is exactly the same as docker-compose run web /bin/bash (but shorter 😉).
This docker recipe was based on the Evil Martians blog post