Collection of containers to run the Enroll ecosystem in a development context
Download and install Docker Desktop.
Clone the ea_enterprise repo:
git clone https://github.com/ideacrew/ea_enterprise.git
Copy the env-example.dev to env.dev and change the values as needed (don't commit env files)
cp env-example.dev env.dev
Ensure the other repositories are present on your local machine and at the same level as ea_enterprise:
- enroll
- fdsh_gateway
- medicaid_gateway
- medicaid_eligibility
- aca_entities
- polypress
the layout should look like this (you can change the projects folder)
~ /
└── projects/
├── ea_enterprise
├── enroll
├── fdsh_gateway
├── medicaid_gateway
├── aca_entities
└── polypress
Be sure all repositories are up to date with their respective release branches before running any commands!
-
inside the container: this means we will run a command inside the container, for example,
docker-compose exec enroll /bin/bash
will run the command/bin/bash
inside the containerenroll
from there we can execute any command that is available inside the container, for example,rails c
will open a rails console inside the container -
outside the container: this means we will run a command on the "host", usually in the context of the developer's Mac.
-
mongoid.yml: The services
fdsh_gateway
,enroll
has "localhost" as the "server" on config/mongoid.yml, the docker-compose configuration "patches" this by mounting anther configuration, the "patched" configuration is located atconfig/mongoid.yml.docker
and is mounted on the container at/{APP}/config/mongoid.yml
-
local aca_entities: Local aca_entities: it is already mounted and can be changed on the Gemfile, the trick is just to restart the service you are working with (i.e., restart only Enroll if you are updating Enroll's Gemfile).
- docker-compose up
- wait
- modify the gemfile point to a file path
gem 'aca_entities', path: "/aca_entities"
- restart just enroll via the ui or command line (do not restart everything)
- stimulus reflex on MG
Docker-compose will patch MG stimulus reflex initializer to ignore dev:cache not being enabled, this is done via a volume mount on the docker-compose.yml file, the file is located at
hotpatches/stimulus_reflex.rb
and is mounted on the container at/{APP}/config/initializers/stimulus_reflex.rb
.
Note: commands must be run in the terminal from inside the ea_enterprise directory.
- Start all services
docker-compose up
- Start enroll and any of its dependencies
docker-compose up enroll
- Start 2 services
docker-compose up enroll fdsh_gateway
- Rebuild all the containers
docker-compose build
- Rebuild specific container (example; enroll container)
docker-compose build enroll
- Shell inside a container
docker-compose exec enroll /bin/bash
- Rubocop inside enroll
docker-compose exec enroll /enroll/rubocop_check_last_commit.sh
docker-compose exec enroll /enroll/rubocop_check_pre_commit.sh
- docker-compose "exec vs run"
The slight difference between exec and run is that run will create a new container, and exec will run the command on an existing container, examples;
- this will execute /bin/bash under the running container enroll, if there is no enroll running, the command will fail
docker-compose exec enroll /bin/bash
- this will create a new container and inside it will execute /bin/bash, if there is a container running, it will not be affected and create a new one in parallel, if there is no enroll running it will not fail
docker-compose run enroll /bin/bash
Make sure Mongo is running
cd ea_enterprise
docker compose cp ~/projects/dumps/super_dump/ mongodb:/dump
docker-compose exec mongodb mongorestore
- start a console (from outside, to the container)
docker-compose exec enroll rails c
- run tests (inside the container):
RAILS_ENV=test bundle exec rspec components/financial_assistance/spec/
- run test outside the container (cd to ea_enterprise first):
docker-compose exec -e "RAILS_ENV=test" enroll bundle exec rspec components/financial_assistance/spec/
- open rails console (inside the container):
Very similar to the rules regarding when to restart a rails application
- You changed something under /config
- You need to switch branches
- you added or deleted a gem
- you changed anything docker-compose.yml file
- you changed the Dockerfile of any container
The IdeaCrew GHA runs the specs as "engines" that means it runs the specs for each component separately from the main enroll app. This can now be run under docker by following this method.
- start the containers
docker-compose up
- open a shell on the running enroll
docker-compose exec enroll bash
- go to the component you want to run the specs for example financial assitance
cd components/financial_assistance
- bundle install
bundle install
- run the specs
bundle exec rspec
It is possible to run cucumber, however, there are 2 drawbacks; first is that the gem webdrivers have to be removed manually and the container restarted, and the second drawback is that it uses a "modified" env.rb that removes all the references to the webdriver gem, this is done automatically via a virtual volume on docker-compose (as end user you don't need to worry about this unless something big changes on cucumber).
These are the steps to enable cucumber
- On enroll edit the Gemfile and remove:
gem 'webdrivers', '~> 3.0'
- Trigger a restart for enroll with
docker-compose restart enroll
- run cucumber
- from inside the container (attach a shell to the container first)
NODE_ENV=test RAILS_ENV=test bundle exec cucumber features/financial_assistance/view_eligibility.feature
- from outside the container (inside the ea_enterprise directory):
docker-compose exec -e "RAILS_ENV=test" enroll bundle exec cucumber features/financial_assistance/view_eligibility.feature
After rebuilding the container for the first time, only step 3 is needed
- rspec
uninitialized constant Mongoid::Matchers
you are not running the specs on test environment, run them with RAILS_ENV=test bundle exec rspec
Some people complain about "writing" speed, and it's true, it's slow, however on the "experimental features", there is a new option called "VirtioFS" and it's fast, close to native fast, the recommendation is to enable it
-
how do I enter the rails console? use
docker exec -it <container name>
/bin/bash, or via the UI there is a button to do this quickly -
why we are not executing bundle install on docker-compose? <- it's slower, and in theory, gems should not change that much
-
why the shell inside the container doesn't respond to the arrows or any other shell nicety? (usually, this happens when using the docker UI) it's because it's executing /bin/sh, you can execute /bin/bash as soon as the terminal is open
- add scripts to open the console quickly
- add scripts to run rubocop/tests
- fix/add the Nginx in front of the services that have them on production (the one in Medicaid gateway is not fully configured yet)