2023-05-18 18:09:55 +00:00
# Using Docker
2023-05-18 18:09:57 +00:00
To quickly get started, run the command `make docker` .
2023-05-18 18:09:55 +00:00
If docker is installed the Makefile will export extra targets in the fomrat `docker.*` to build and run the docker image. Type `make` for a list of available tasks.
2023-05-18 18:09:57 +00:00
2023-05-18 18:09:55 +00:00
There is a basic `docker-compose.yml` in the docker directory.
2023-05-18 18:09:57 +00:00
2023-05-18 18:09:55 +00:00
## Building the development image
2023-05-18 18:09:57 +00:00
2023-05-18 18:09:55 +00:00
Using `make docker` will build the dev image if it does not exist, then drops
you inside the container with the langchain environment available in the shell.
### Customizing the image and installed dependencies
2023-05-18 18:09:57 +00:00
The image is built with a default python version and all extras and dev
dependencies. It can be customized by changing the variables in the [.env ](/docker/.env )
file.
If you don't need all the `extra` dependencies a slimmer image can be obtained by
commenting out `POETRY_EXTRA_PACKAGES` in the [.env ](docker/.env ) file.
2023-05-18 18:09:55 +00:00
### Image caching
2023-05-18 18:09:57 +00:00
The Dockerfile is optimized to cache the poetry install step. A rebuild is triggered when there a change to the source code.
2023-05-18 18:09:55 +00:00
## Example Usage
2023-05-18 18:09:57 +00:00
2023-05-18 18:09:55 +00:00
All commands from langchain's python environment are available by default in the container.
2023-05-18 18:09:57 +00:00
A few examples:
```bash
# run jupyter notebook
docker run --rm -it IMG jupyter notebook
# run ipython
docker run --rm -it IMG ipython
# start web server
docker run --rm -p 8888:8888 IMG python -m http.server 8888
```
2023-05-18 18:09:55 +00:00
## Testing / Linting
Tests and lints are run using your local source directory that is mounted on the volume /src.
Run unit tests in the container with `make docker.test` .
Run the linting and formatting checks with `make docker.lint` .
Note: this task can run in parallel using `make -j4 docker.lint` .