https://help.github.com/articles/fork-a-repo/
- Windows 10 (Pro/Enterprise, 64-bit): https://store.docker.com/editions/community/docker-ce-desktop-windows
- macOS El Capitan 10.11 and newer: https://store.docker.com/editions/community/docker-ce-desktop-mac
(Other Mac or Windows OS? See instructions for Docker Toolbox.)
(Running Linux? See instructions for Docker CE on Linux.)
Trouble with docker? The Troubleshooting Docker wiki outlines solutions for common errors.
Build the containers from any terminal program with:
docker-compose build
Optional: list the containers you just built:
docker ps
You should see two containers: refugerestrooms_web and postgres.
You can now run the app with:
docker-compose up
The web app will be reachable at this address: localhost:3000
(Point your web browser at localhost:3000
or 127.0.0.1:3000
, or even [IP address of computer running the container]:3000
from any computer on the same LAN. The last method is useful for testing the app/site on smart phones and tablets.)
Files are shared between your computer and the Docker machine. If you update a file on your computer, the change should show up on the Docker machine, and vice-versa.
If you need to run commands on the Docker container directly, run this:
docker-compose run web bash
(This will give you a full interactive terminal session running on the Docker machine. For example, run bundle update
to update the Gems in the Gemfile to more recent versions, or rails console
to access web objects like Restroom.first
.)
Occasionally, you might need to rebuild the Docker machine so it picks up major updates (such as a new version of Ruby, or an updated Gemfile). To do so, run docker-compose down
and docker-compose build
.
If you want to access the postgres container to reach the psql command line do
docker-compose run db bash
psql -h refugerestrooms_db_1 -U postgres
or equivalently:
docker-compose run db psql -h refugerestrooms_db_1 -U postgres
docker-compose run -e "RAILS_ENV=test" web rake db:migrate:reset spec
(If you want to know if your changes pass our automated testing, before even submitting your changes to RefugeRestrooms on Github, this will let you know.)
If you want to run an individual spec, first log in to the container, then the spec. E.g.:
docker-compose run web bash
rspec spec/models/restroom_spec.rb
This is equivalent, but slower during a code-test-code-test development cycle:
docker-compose run web rspec spec/models/restroom_spec.rb
Ruby code is linted with rubocop.
If you want to lint your code before pushing it, you can run:
docker-compose run web rubocop
Some lint issues can be resolved automatically by running:
docker-compose run web rubocop --auto-correct
In another terminal window, run:
docker-compose down
(Shutting down the container in this way is safer than exiting with Ctrl + C
, and prevents issues with breaking the db
container.)
To clean up encoding problems in the safe2pee data, run (Use rake db:fix_accents[dry_run]
to preview the changes.):
docker-compose run rake db:fixaccents
Please cover any new code with specs. We prefer code to be covered using RSpec or Capybara.
Checkout our Wiki and specifically the newcomers guide.
Please also read our Code of Conduct, which gives guidance on our standards of community and interaction.