Skip to content

BerkeleyLibrary/geodata

Repository files navigation

Geodata

Geodata web portal developed from Geoblacklight 4.1.0 Geodata@UCB

Docker

# Build container images
docker-compose build --pull --force-rm

# Start the stack in the background
docker-compose up --d

# Run setup tasks (create databases, compile assets, etc.)
docker-compose run --rm --entrypoint=setup app

Accessing Services

Configuration

Sensitive settings like the DATABASE_URL, SOLR_URL, and SECRET_KEY_BASE are provided to the application by Docker "secrets". In development, these are stored in secrets/dev and you don't have to worry about them. In production, they're provided by the production infrastructure.

Just know that they're there.

The mechanics of loading them into the application are fairly simple:

  • Docker puts those in read-only files under /run/secrets within the container.
  • On startup, the application reads all files in that directory and overrides their corresponding ENV variables. For example, the file /run/secrets/DATABASE_URL clobbers the ENV['DATABASE_URL'] environment variable.
  • This is preferable to storing that in the actual environment because it ensures only the Rails process can see that config value. It's also convenient, though, because you can use ENV to access the value.

If you're curious, the code that does this is in config/application.rb.

Helpful Commands

View logs:

docker-compose logs -f # tail all logs
docker-compose logs -f app # tail just the "app" service's logs (etc.)

Shell into a container:

docker-compose run --rm --entrypoint=ash app

Open a Rails console:

docker-compose run --rm app console

Stop services and clean up volumes:

docker-compose down -v

Deployment

Staging

Production