|
| 1 | +In this page you will find our recommended way of installing Docker on your machine. |
| 2 | +This guide is made for macOS users. |
| 3 | + |
| 4 | +## Install docker |
| 5 | + |
| 6 | +Install [Docker Desktop](https://docs.docker.com/get-docker/). |
| 7 | + |
| 8 | +## Build the image |
| 9 | + |
| 10 | +```bash |
| 11 | +docker build -t algolia-js --build-arg NODE_IMAGE=node:$(cat .nvmrc)-alpine . |
| 12 | +``` |
| 13 | + |
| 14 | +## Run the image |
| 15 | + |
| 16 | +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). |
| 17 | +You can set them up directly in the command: |
| 18 | + |
| 19 | +```bash |
| 20 | +docker run -it --rm --env ALGOLIA_APP_ID=XXXXXX [...] -v $PWD:/app -v /app/node_modules -w /app algolia-js bash |
| 21 | +``` |
| 22 | + |
| 23 | +However, we advise you to 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 set your variables. |
| 24 | + |
| 25 | +```bash |
| 26 | +### This is needed only to run the full test suite |
| 27 | +docker run -it --rm --env ALGOLIA_APPLICATION_ID_1 \ |
| 28 | + --env ALGOLIA_ADMIN_KEY_1 \ |
| 29 | + --env ALGOLIA_SEARCH_KEY_1 \ |
| 30 | + --env ALGOLIA_APPLICATION_ID_2 \ |
| 31 | + --env ALGOLIA_ADMIN_KEY_2 \ |
| 32 | + --env ALGOLIA_APPLICATION_ID_MCM \ |
| 33 | + --env ALGOLIA_ADMIN_KEY_MCM \ |
| 34 | +-v $PWD:/app -v /app/node_modules -w /app algolia-js bash |
| 35 | +``` |
| 36 | + |
| 37 | +Once your container is running, any changes you make in your IDE are directly reflected in the container, except for the `node_modules` folder. |
| 38 | +If you want to add or remove packages, you will have to rebuild the image, this is because the `node_modules` folder is installed in a different folder to improve performance. |
| 39 | + |
| 40 | +To launch the tests, you can use one of the following commands |
| 41 | +```shell script |
| 42 | +# run only the unit tests |
| 43 | +yarn test:unit |
| 44 | + |
| 45 | +# run a single test |
| 46 | +yarn test:unit nameOfYourTest |
| 47 | +``` |
| 48 | + |
| 49 | +You can find more commands in the `package.json` file. |
| 50 | + |
| 51 | +Feel free to contact us if you have any questions. |
0 commit comments