ensl.org/DEVELOPMENT.md
Ari Timonen 75b33e760a Move back to docker-compose + fix env vars
Fix env vars. Rely on inheritance.
Add a script to load env vars as above.
Fix staging env
Add nginx conf and SSL directory
Reorganize .gitignore
Use multi-staged docker-compose + dockerfile
Substitute env vars for static values
2020-04-05 05:58:41 +03:00

2.8 KiB

Development

Install instructions in INSTALL.md

Startup

Just run and open http://localhost:4000/

docker-compose -f docker-compose.yml up`

Tips

  1. Everything should be running on containers.

  2. If you need to run stuff on your host (eg. ruby, rubocop, bundle install etc) run all commands from the: Dockerfile.dev. It should setup identical setup for your machine.

  3. Add docker container names to /etc/hosts. This makes it possible to run test from local machine without using the container since editor/IDE don't integrate with Docker so well.

    sudo echo docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ensl_dev_db db >> /etc/hosts

  4. VS Code and RubyMine are great IDE's/editors.

  5. To run VS Code plugin Ruby Test Explorer in docker container you need to create path to custom path, copy the formatter and it whines about and it still fails a bit. https://github.com/connorshea/vscode-ruby-test-adapter/issues/21

  6. Do not commit too much without testing. Also keep commits small for documentation and reversability issues.

  7. You need to rebuild the docker image when you change gems.

TODO issues for dev

  1. Puma should be running (eg. spring), and if debugger is used it should be able to connect via docker-compose up
  2. Should directories exist?

Tags in code

FIXME, TODO, EXPLAIN, OBSOLETE

Handy commands

Load env variables:

export $(cat .env.development | xargs) && export $(cat .env | xargs)

Start:

docker-compose -f docker-compose.yml up -d --build`

Build or rebuild:

docker-compose -f docker-compose.yml build`

Debug:

docker attach ensl_dev

To get inside docker web+test containers:

docker-compose -f docker-compose.yml exec -u root web /bin/bash`
docker-compose -f docker-compose.yml exec -u web web /bin/bash`
docker-compose -f docker-compose.yml exec -u root test /bin/bash`
docker-compose -f docker-compose.yml exec -u web test /bin/bash`

Restart the web container

docker-compose -f docker-compose.yml restart web`

Run some tests:

docker-compose -f docker-compose.yml exec -u web test bundle exec rspec`
docker-compose -f docker-compose.yml exec -u web test bundle exec rspec spec/controllers/shoutmsgs_controller_spec.rb`

Design of ENSL Application

Read this to understand design decisions and follow them!

  1. Env variables should be used everywhere and loaded from .env* files using Dotenv
  2. The app contents are added to the docker image on build but it is mounted as volume.
  3. Use rails / ruby best practices in section below.

Best practices

  1. https://nvie.com/posts/a-successful-git-branching-model/
  2. https://github.com/rubocop-hq/ruby-style-guide
  3. https://rails-bestpractices.com/
  4. http://www.betterspecs.org/
  5. https://github.com/rubocop-hq/rspec-style-guide
  6. Run rubocop