Skip to content

Commit eefc439

Browse files
Add DOCKER_README and update README with Docker section (#703)
1 parent 5c3dd49 commit eefc439

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

DOCKER_README.MD

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
In this page you will find our recommended way of installing Docker on your machine.
2+
This guide is made for OSX users.
3+
4+
## Install docker
5+
6+
First install Docker using [Homebrew](https://brew.sh/)
7+
```
8+
$ brew install docker
9+
```
10+
11+
You can then install [Docker Desktop](https://docs.docker.com/get-docker/) if you wish, or use `docker-machine`. As we prefer the second option, we will only document this one.
12+
13+
## Setup your docker
14+
15+
Install `docker-machine`
16+
```
17+
$ brew install docker-machine
18+
```
19+
20+
Then install [VirtualBox](https://www.virtualbox.org/) with [Homebrew Cask](https://github.com/Homebrew/homebrew-cask) to get a driver for your Docker machine
21+
```
22+
$ brew cask install virtualbox
23+
```
24+
25+
You may need to enter your password and authorize the application in your `System Settings` > `Security & Privacy`.
26+
27+
Create now a new machine, set it up as default and connect your shell to it (here we use zsh. The commands should anyway be displayed in each steps' output)
28+
29+
```
30+
$ docker-machine create --driver virtualbox default
31+
$ docker-machine env default
32+
$ eval "$(docker-machine env default)"
33+
```
34+
35+
Now you're all setup to use our provided Docker image!
36+
37+
## Build the image
38+
39+
```bash
40+
docker build -t algolia-swift .
41+
```
42+
43+
## Run the image
44+
45+
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).
46+
You can set them up directly in the command:
47+
48+
```bash
49+
docker run -it --rm --env ALGOLIA_APP_ID=XXXXXX [...] -v $PWD:/app -w /app algolia-swift bash
50+
```
51+
52+
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.
53+
54+
```bash
55+
### For external contributors, only the following env variables should be enough
56+
docker run -it --rm --env ALGOLIA_APPLICATION_ID_1 \
57+
--env ALGOLIA_ADMIN_KEY_1 \
58+
--env ALGOLIA_SEARCH_KEY_1 \
59+
-v $PWD:/app -w /app algolia-swift bash
60+
61+
### This is needed only to run the full test suite
62+
docker run -it --rm --env ALGOLIA_APPLICATION_ID_1 \
63+
--env ALGOLIA_ADMIN_KEY_1 \
64+
--env ALGOLIA_SEARCH_KEY_1 \
65+
--env ALGOLIA_APPLICATION_ID_2 \
66+
--env ALGOLIA_ADMIN_KEY_2 \
67+
--env ALGOLIA_APPLICATION_ID_MCM \
68+
--env ALGOLIA_ADMIN_KEY_MCM \
69+
-v $PWD:/app -w /app algolia-swift bash
70+
```
71+
72+
Once your container is running, any changes you make in your IDE are directly reflected in the container.
73+
74+
To launch the tests, you can use the following command
75+
```shell script
76+
swift test
77+
```
78+
79+
Feel free to contact us if you have any questions.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ For full documentation, visit the [Algolia Swift API Client's documentation](htt
196196

197197
You can find code samples in the [Algolia's API Clients playground](https://github.com/algolia/api-clients-playground/tree/master/swift).
198198

199+
## Use the Dockerfile
200+
201+
If you want to contribute to this project without installing all its dependencies, you can use our Docker image. Please check our [dedicated guide](DOCKER_README.MD) to learn more.
202+
199203
## 📄 License
200204

201205
Algolia Swift API Client is an open-sourced software licensed under the [MIT license](LICENSE).

0 commit comments

Comments
 (0)