mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-07 08:08:20 +00:00
Add dockerfile template (#13240)
This commit is contained in:
parent
f70aa82c84
commit
f55f67055f
21
libs/cli/langchain_cli/project_template/Dockerfile
Normal file
21
libs/cli/langchain_cli/project_template/Dockerfile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
RUN pip install poetry==1.6.1
|
||||||
|
|
||||||
|
RUN poetry config virtualenvs.create false
|
||||||
|
|
||||||
|
WORKDIR /code
|
||||||
|
|
||||||
|
COPY ./pyproject.toml ./poetry.lock* ./
|
||||||
|
|
||||||
|
COPY ./packages ./packages
|
||||||
|
|
||||||
|
RUN poetry install --no-interaction --no-ansi --no-root
|
||||||
|
|
||||||
|
COPY ./app ./app
|
||||||
|
|
||||||
|
RUN poetry install --no-interaction --no-ansi
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
CMD exec uvicorn app.server:app --host 0.0.0.0 --port 8080
|
@ -47,3 +47,33 @@ export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "defaul
|
|||||||
```bash
|
```bash
|
||||||
langchain serve
|
langchain serve
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Running in Docker
|
||||||
|
|
||||||
|
This project folder includes a Dockerfile that allows you to easily build and host your LangServe app.
|
||||||
|
|
||||||
|
### Building the Image
|
||||||
|
|
||||||
|
To build the image, you simply:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker build . -t my-langserve-app
|
||||||
|
```
|
||||||
|
|
||||||
|
If you tag your image with something other than `my-langserve-app`,
|
||||||
|
note it for use in the next step.
|
||||||
|
|
||||||
|
### Running the Image Locally
|
||||||
|
|
||||||
|
To run the image, you'll need to include any environment variables
|
||||||
|
necessary for your application.
|
||||||
|
|
||||||
|
In the below example, we inject the `OPENAI_API_KEY` environment
|
||||||
|
variable with the value set in my local environment
|
||||||
|
(`$OPENAI_API_KEY`)
|
||||||
|
|
||||||
|
We also expose port 8080 with the `-p 8080:8080` option.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker run -e OPENAI_API_KEY=$OPENAI_API_KEY -p 8080:8080 my-langserve-app
|
||||||
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user