|
| 1 | +This guide shows our recommended recommended way of installing Docker on your OS X machine. |
| 2 | + |
| 3 | +## Install docker |
| 4 | + |
| 5 | +First install Docker using [Homebrew](https://brew.sh/) |
| 6 | +``` |
| 7 | +$ brew install docker |
| 8 | +``` |
| 9 | + |
| 10 | +You can install [Docker Desktop](https://docs.docker.com/get-docker/) if you wish, or use the `docker-machine` command to work with your Docker containers. This guide assumes you use the `docker-machine` command. |
| 11 | + |
| 12 | +## Setup your Docker |
| 13 | + |
| 14 | +Install `docker-machine` |
| 15 | +``` |
| 16 | +$ brew install docker-machine |
| 17 | +``` |
| 18 | + |
| 19 | +Then install [VirtualBox](https://www.virtualbox.org/) using [Homebrew Cask](https://github.com/Homebrew/homebrew-cask) to get a driver for your Docker machine |
| 20 | +``` |
| 21 | +$ brew cask install virtualbox |
| 22 | +``` |
| 23 | + |
| 24 | +You may need to enter your password and authorize the application through `System Settings` > `Security & Privacy`. |
| 25 | + |
| 26 | +Create a new machine, and set it up as default, and connect your shell to the machine with the following commands: |
| 27 | + |
| 28 | +``` |
| 29 | +$ docker-machine create --driver virtualbox default |
| 30 | +$ docker-machine env default |
| 31 | +$ eval "$(docker-machine env default)" |
| 32 | +``` |
| 33 | + |
| 34 | +Now you're all setup to use our provided Docker image! |
| 35 | + |
| 36 | +## Build the image |
| 37 | + |
| 38 | +```bash |
| 39 | +docker build -t algolia-ruby . |
| 40 | +``` |
| 41 | + |
| 42 | +## Run the image |
| 43 | + |
| 44 | +You need to provide few environment variables at runtime to be able to run the [Common Test Suite](https://github.com/algolia/algoliasearch-client-specs/tree/master/common-test-suite). |
| 45 | +You can set them up directly in the command |
| 46 | + |
| 47 | +```bash |
| 48 | +docker run -it --rm --env ALGOLIA_APPLICATION_ID_1=XXXXXX [...] -v $PWD:/app -w /app algolia-ruby bash |
| 49 | +``` |
| 50 | + |
| 51 | +But we advise you export them in your `.bashrc` or `.zshrc`. That way, you can use [Docker's shorten syntax](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file) to retrieve your variables. |
| 52 | + |
| 53 | +```bash |
| 54 | +### For external contributors, only the following env variables should be enough |
| 55 | +docker run -it --rm --env ALGOLIA_APPLICATION_ID_1 \ |
| 56 | + --env ALGOLIA_ADMIN_KEY_1 \ |
| 57 | + --env ALGOLIA_SEARCH_KEY_1 \ |
| 58 | +-v $PWD:/app -w /app algolia-ruby bash |
| 59 | + |
| 60 | +### This is needed only to run the full test suite |
| 61 | +docker run -it --rm --env ALGOLIA_APPLICATION_ID_1 \ |
| 62 | + --env ALGOLIA_ADMIN_KEY_1 \ |
| 63 | + --env ALGOLIA_SEARCH_KEY_1 \ |
| 64 | + --env ALGOLIA_APPLICATION_ID_2 \ |
| 65 | + --env ALGOLIA_ADMIN_KEY_2 \ |
| 66 | + --env ALGOLIA_APPLICATION_ID_MCM \ |
| 67 | + --env ALGOLIA_ADMIN_KEY_MCM \ |
| 68 | +-v $PWD:/app -w /app algolia-ruby bash |
| 69 | +``` |
| 70 | + |
| 71 | +Once the container is up, you can edit files directly in your IDE: changes will be mirrored in the image. |
| 72 | + |
| 73 | +Lastly to launch the tests, you can use one of the following commands |
| 74 | +```shell script |
| 75 | +# run only the unit tests |
| 76 | +bundle exec rake test:unit |
| 77 | + |
| 78 | +# run only the integration tests |
| 79 | +bundle exec rake test:integration |
| 80 | + |
| 81 | +# run the whole test suite |
| 82 | +bundle exec rake test:all |
| 83 | + |
| 84 | +# run a single test |
| 85 | +bundle exec rake test TEST=/full/path/to/test.rb TESTOPTS="--name=test_name" |
| 86 | +``` |
| 87 | + |
| 88 | +Feel free to contact us if you have any questions. |
0 commit comments