-
Notifications
You must be signed in to change notification settings - Fork 608
Docker
Docker is a container platform that makes it easier to start a development environment with all the required dependencies. This is an alternative to using virtual machines (such as Vagrant).
To start you only need to have git and docker installed. Everything else will be done via Docker itself.
Note: If you do not install the Desktop version of Docker, such as with a Linux-based OS, make sure to also install Docker Compose.
Attention: For Windows you should set git parameter core.autocrlf
to input
, otherwise you will get \r\n
linebreaks and it will break some scripts!
For security, you should modify the default database password before starting your local environment, unless you trust your firewall and everyone on your local network.
- In
config/docker/database.yml
, change the default DB password ("change_me"). - In
docker-compose.yml
, change the MySQL root password to the same value (also default "change_me").
In the shell of your choice, navigate to the repository root and run the initialization script.
For Unix-like systems such as Linux or macOS:
./script/docker/init.sh
Or for Windows:
script\docker\init.cmd
This will pull and build all required Docker images, copy all the required configuration files, run the initialization tasks (setting up the database, indexing for search, etc.) and finally start the Rails application.
When the script has finished, you should be able to access your archive by visiting http://localhost:3000/ in the browser of your choice.
If you cannot access your archive there, you will likely end up needing to re-run the init script after fixing the issue--simply running docker-compose up -d web
may appear to succeed while skipping critical steps.
If you're on Linux and the version of the archive that shows up on localhost seems to be missing a lot of the css, you may need to change the ownership of the files docker generated, as in the official Rails on Docker Compose example, and then re-run the init script. In particular it's the permissions of the files in public/system/skins/
that cause the css issue, but all files created by Docker are owned by root, and this can cause problems when trying to access them from within the container:
sudo chown -R $USER:$USER .
If you run into a cp: illegal option --b
on macOS, try installing coreutils
with Homebrew (brew install coreutils
) and updating ./script/docker/init.sh
with gcp
instead of cp
.
After the one-off initialization tasks have been run, on subsequent starts you can open your shell and use the following:
docker-compose up -d web
Then you will be able to access your archive by visiting http://localhost:3000/ in the browser of your choice.
You can start a Rails console in the development environment:
docker-compose exec web bundle exec rails c
Or get a shell inside the container and execute commands as you would normally:
docker-compose exec web bash
Refer to Development Data for creating admin and user accounts in your development environment.
To create your search indexes (and fill them with data), you'll need to start the background workers.
In the commands below, note that the file paths, such as spec/my_model_spec.rb:10
, are examples. You will have to put in the correct file path to the tests you would like to run. If you would like to run all of the tests, use spec
for RSpec tests and features
for Cucumber tests.
To run RSpec tests:
docker-compose run --rm test bundle exec rspec spec/my_model_spec.rb:10
To run Cucumber tests:
docker-compose run --rm test bundle exec cucumber features/my_archive_process.feature:10
If there have been changes to the Dockerfile
setup (e.g. new gem updates), you'll need to rebuild the containers:
docker-compose up --build --force-recreate --no-deps -d web test
If you have any questions regarding code development, please don't hesitate to send an email to [email protected] and we will try to get back to you as soon as possible!
- Home
- Set Up Instructions
- Docker (All platforms)
- Gitpod (Cloud-based development)
- Linux
- OS X
- Creating Development Data
- Writing and Tracking Code
- Automated Testing
- Architecture
-
Getting Started Guide
- Getting Set Up
- Your First Pull Request
- More About Git
- Jira