Skip to content

Commit 8845e03

Browse files
authored
chore(docker): Add a Dockerfile and a guide to setup Docker (#614)
1 parent dc86535 commit 8845e03

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

DOCKERFILER_README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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-scala .
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-scala 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-scala 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-scala 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 build and run tests, you can use the following commands:
75+
```shell script
76+
# build the project
77+
sbt compile
78+
79+
# run tests
80+
sbt test
81+
```
82+
83+
Feel free to contact us if you have any questions.

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM openjdk:11
2+
3+
RUN echo "deb https://dl.bintray.com/sbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list
4+
RUN curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key add
5+
RUN apt-get update && apt-get install sbt
6+
7+
WORKDIR /app
8+
COPY . /app/
9+
10+
RUN sbt update

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,5 +197,9 @@ For full documentation, visit the **[Algolia Scala API Client](https://www.algol
197197

198198
Encountering an issue? Before reaching out to support, we recommend heading to our [FAQ](https://www.algolia.com/doc/api-client/troubleshooting/faq/scala/) where you will find answers for the most common issues and gotchas with the client.
199199

200+
## Use the Dockerfile
201+
202+
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.
203+
200204
## 📄 License
201205
Algolia Scala API Client is an open-sourced software licensed under the [MIT license](LICENSE.md).

0 commit comments

Comments
 (0)