Office Moms and Dads Scheduler
Development Environment Setup
Note: remove boot2docker or other Docker implementations if any were previously installed
cp env.example .env
Note: There exists a .env file in 1Password intended for development. Note: On Mac, make sure to append
COMPOSE_FILEto take advantage of cached volumes
Open a browser to localhost:3000 verify the app is up.
Helpful Docker Commands
docker-compose upStarts fresh containers
-dstarts it in daemon mode
docker-compose downStops and removes containers(all data too)
docker-compose stopStops running containers but persists data
docker-compose startStarts containers with persisted data
docker system pruneCleans up unused containers, networks, and images
Note: it is recommended to run the clean up commands weekly
docker psLists all running containers
docker-compose run app bashStarts a bash session on app, bringing up only dependent services.
docker exec -it ID_FROM_DOCKER_PS bash. Connects another bash session to a running container.
docker attach ID_FROM_DOCKER_PSAttach is useful for pry debugging in a running container
Note: To detach use
ctrl-p + ctrl-q
Rails Commands in a Docker World
Now that the app is running in Docker we will run all Rails and Rake commands in the container.
Here are a few examples:
Note: this is expecting the containers are up
docker-compose exec app bundle exec rake db:migrate
docker-compose exec app bundle exec rails c
The pattern is docker-compose exec (container_name) rails or rake command. This pattern works for non-Rails commands also.
docker-compose exec app bashwill open the terminal on the container
System tests open the browser and make assertions against the content of the page or verify expected behavior. These tests can be run in headless mode (the default), which means that they are executed in a virtual browser. If you would like them to be run in an actual, viewable browser, you will need to disable headless mode by setting the HEADLESS environment variable to 'false' and ensure you have the ChromeDriver WebDriver downloaded and installed on your host machine.
HEADLESS=false bundle exec rspec spec/system/mytest_spec.rb
If you are running in non-headless mode, you'll need to be sure you have the ChromeDriver running and able to accept connections from the IP the server is running on. This can be done by running ChromeDriver in a separate tab/console via: