-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docker): containerize repo (#538)
* chore(docker): containerize repo * fix: simplify `Dockerfile`
- Loading branch information
Showing
5 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
In this page you will find our recommended way of installing Docker on your machine. | ||
This guide is made for OSX users. | ||
|
||
## Install docker | ||
|
||
First install Docker using [Homebrew](https://brew.sh/) | ||
|
||
``` | ||
$ brew install docker | ||
``` | ||
|
||
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. | ||
|
||
## Setup your docker | ||
|
||
Install `docker-machine` | ||
|
||
``` | ||
$ brew install docker-machine | ||
``` | ||
|
||
Then install [VirtualBox](https://www.virtualbox.org/) with [Homebrew Cask](https://github.com/Homebrew/homebrew-cask) to get a driver for your Docker machine | ||
|
||
``` | ||
$ brew cask install virtualbox | ||
``` | ||
|
||
You may need to enter your password and authorize the application in your `System Settings` > `Security & Privacy`. | ||
|
||
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) | ||
|
||
``` | ||
$ docker-machine create --driver virtualbox default | ||
$ docker-machine env default | ||
$ eval "$(docker-machine env default)" | ||
``` | ||
|
||
Now you're all setup to use our provided Docker image! | ||
|
||
## Build the image | ||
|
||
```bash | ||
docker build -t algolia-python . | ||
``` | ||
|
||
## Run the image | ||
|
||
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). | ||
You can set them up directly in the command: | ||
|
||
```bash | ||
docker run -it --rm --env ALGOLIA_APPLICATION_ID_1=XXXXXX [...] $PWD:/algoliasearch -w /algoliasearch algolia-python bash | ||
``` | ||
|
||
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. | ||
|
||
```bash | ||
### This is needed only to run the full test suite | ||
docker run -it --rm --env ALGOLIA_ADMIN_KEY_MCM \ | ||
--env ALGOLIA_APPLICATION_ID_MCM \ | ||
--env ALGOLIA_ADMIN_KEY_2 \ | ||
--env ALGOLIA_APPLICATION_ID_2 \ | ||
--env ALGOLIA_SEARCH_KEY_1 \ | ||
--env ALGOLIA_ADMIN_KEY_1 \ | ||
--env ALGOLIA_APPLICATION_ID_1 \ | ||
-v $PWD:/algoliasearch -w /algoliasearch algolia-python bash | ||
``` | ||
|
||
Once your container is running, any changes you make in your IDE are directly reflected in the container. | ||
|
||
To launch the tests, you can use one of the following commands | ||
|
||
```shell script | ||
# run format check | ||
tox -e format | ||
|
||
# run type check | ||
tox -e types | ||
|
||
# run tests for specific version | ||
tox -e py38-sync,py38-async | ||
``` | ||
|
||
You can find more commands in the [tox.ini](./tox.ini) file or the [circleci config](./.circleci/config.yml). | ||
|
||
Feel free to contact us if you have any questions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Dockerfile | ||
FROM python:3.8.2 | ||
|
||
WORKDIR /algoliasearch | ||
ADD . /algoliasearch/ | ||
|
||
# install dev env dependencies | ||
RUN pip install --upgrade pip && \ | ||
pip install -r requirements.txt | ||
# setup dev env | ||
|
||
RUN python3 setup.py install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
setuptools | ||
tox | ||
mypy | ||
requests | ||
types-requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters