Skip to content

How to use Docker CE on Linux with Refuge Restrooms

DeeDeeG edited this page Dec 24, 2019 · 4 revisions

Contributing (Docker CE on Linux)

Setting Up Development Environment

1 Fork and clone the repository.

https://help.github.com/articles/fork-a-repo/

2 Install Docker.

2a Install docker-compose

https://docs.docker.com/compose/install/#install-compose

(Navigate to the Linux tab on this page. Make sure to follow at least Steps 1 and 2 under the Linux tab. Step 1 downloads docker-compose. Step 2 makes it executable. Step 3 adds handy bash or zsh completion.)

3 Build the Docker Container

Build the container from any terminal program with:

sudo docker-compose build

4 Run the Docker Container

You can now run the app with:

sudo docker-compose up

The container 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.)

5 Do some Development

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:

sudo docker-compose run web bash

(This will give you a full interactive terminal session running on the Docker machine. You can (for example) run bundle update to update the Gems in the Gemfile to more recent versions.)

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.

6 Run the Tests

sudo docker-compose run -e "RAILS_ENV=test" web rake db:test:prepare 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.)

7 Shut down the Docker Container:

In another terminal window, run:

sudo docker-compose down

(Shutting down the container in this way is safer than exiting with Ctrl + C or Cmd + C, and prevents issues with breaking the db container.)

8 Optional tasks:

To clean up encoding problems in the safe2pee data, run (Use rake db:fix_accents[dry_run] to preview the changes.):

sudo docker-compose run rake db:fixaccents

Assets

Testing

Please cover any new code with specs. We prefer code to be covered using RSpec or Capybara.

Now What?

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.