-
Notifications
You must be signed in to change notification settings - Fork 7
Docker
We have dockerized a lot of the parts of the ScholarSphere stack. A developer can run the entire stack (presently postgres, minio, rails, and solr) or any combination of components via docker-compose
If you don't have docker installed, you can install Docker via the following commands
brew cask install docker --appdir=~/Applications
open ~/Applications/Docker.app
All of scholarsphere's configuration is done via environment variables. the minimal set of variables to get up and running is in .envrc.sample
copy this into .envrc, fill in the variables (values are in vault) and source it. source .envrc
You can also use direnv to automagically source your .envrc files (https://direnv.net/)
Starting up the whole stack:
docker compose up
Starting up the whole stack (rebuild the container):
If you make changes to the Dockerfile, you may want to rebuild. use the --build
flag to accomplish this
docker compose up --build
Starting up bits of the stack (lets say you want to run rails locally, and run minio and solr in docker)
docker compose up solr minio
docker-compose commands will run foregrounded, you can shoot them to the background by using the -d
flag. For example:
docker compose up -d solr
docker compose exec web bundle exec rails db:seed
If you need to run commands in the context of the rails application, you can do so by running the following prefix
docker compose exec web {{ command }}
Examples of things you might want to do
docker compose exec web bundle install
docker compose exec web rails c
You can run the entire test suite within a container:
docker compose exec web bash
bundle exec rake solr:init
export RAILS_ENV=test
bundle exec rspec
To run a specific test outside of the container:
docker compose exec -e RAILS_ENV=test web bundle exec rspec path/to/spec
Note: you may need to run rake solr:init
prior to this.
Attach to the web container to do things like use binding.pry
If you Ctrl-C an attached session, you will need to restart the container
docker attach scholarsphere-web-1
By default docker-compose will run foregrounded, and all the logs will be smashed together. I like to run in daemon mode, and then look at the logs on a service by service basis.
docker-compose logs solr
and to follow the logs
docker-compose logs -f solr
Shut it all down!
docker-compose down
Shut only bits down
docker-compose down minio
Stateful data is handled via docker volumes. minio, solr, and postgres all house their data on named volumes. this allows a developer to maintain databases, indexes, and files between reboots of the application.
To delete all data for a component of the stack, for example, minio, make sure minio is turned off:
docker-compose down minio
then remove the volume
docker volume ls | grep minio # make note of the volume name. (this name should be deterministic)
docker volume rm scholarsphere-4_minio-data
If you just want to poke around at the data you can mount the volume in a container.
Get a listing of containers:
docker-compose images
Then use the name of the solr container to mount its data at the /data path:
docker run -it -v scholarsphere-4_solr-data:/data ubuntu bash
From within the new shell:
cd /data