mirror of
https://github.com/hwchase17/langchain
synced 2024-10-29 17:07:25 +00:00
ccd916babe
Fixes https://github.com/hwchase17/langchain/issues/6172 As described in https://github.com/hwchase17/langchain/issues/6172, I'd love to help update the dev container in this project. **Summary of changes:** - Dev container now builds (the current container in this repo won't build for me) - Dockerfile updates - Update image to our [currently-maintained Python image](https://github.com/devcontainers/images/tree/main/src/python/.devcontainer) (`mcr.microsoft.com/devcontainers/python`) rather than the deprecated image from vscode-dev-containers - Move Dockerfile to root of repo - in order for `COPY` to work properly, it needs the files (in this case, `pyproject.toml` and `poetry.toml`) in the same directory - devcontainer.json updates - Removed `customizations` and `remoteUser` since they should be covered by the updated image in the Dockerfile - Update comments - Update docker-compose.yaml to properly point to updated Dockerfile - Add a .gitattributes to avoid line ending conversions, which can result in hundreds of pending changes ([info](https://code.visualstudio.com/docs/devcontainers/tips-and-tricks#_resolving-git-line-ending-issues-in-containers-resulting-in-many-modified-files)) - Add a README in the .devcontainer folder and info on the dev container in the contributing.md **Outstanding questions:** - Is it expected for `poetry install` to take some time? It takes about 30 minutes for this dev container to finish building in a Codespace, but a user should only have to experience this once. Through some online investigation, this doesn't seem unusual - Versions of poetry newer than 1.3.2 failed every time - based on some of the guidance in contributing.md and other online resources, it seemed changing poetry versions might be a good solution. 1.3.2 is from Jan 2023 --------- Co-authored-by: bamurtaugh <brmurtau@microsoft.com> Co-authored-by: Samruddhi Khandale <samruddhikhandale@github.com>
41 lines
1.4 KiB
Docker
41 lines
1.4 KiB
Docker
# This is a Dockerfile for the Development Container
|
|
|
|
# Use the Python base image
|
|
ARG VARIANT="3.11-bullseye"
|
|
FROM mcr.microsoft.com/devcontainers/python:0-${VARIANT} AS langchain-dev-base
|
|
|
|
USER vscode
|
|
|
|
# Define the version of Poetry to install (default is 1.4.2)
|
|
# Define the directory of python virtual environment
|
|
ARG PYTHON_VIRTUALENV_HOME=/home/vscode/langchain-py-env \
|
|
POETRY_VERSION=1.3.2
|
|
|
|
ENV POETRY_VIRTUALENVS_IN_PROJECT=false \
|
|
POETRY_NO_INTERACTION=true
|
|
|
|
# Create a Python virtual environment for Poetry and install it
|
|
RUN python3 -m venv ${PYTHON_VIRTUALENV_HOME} && \
|
|
$PYTHON_VIRTUALENV_HOME/bin/pip install --upgrade pip && \
|
|
$PYTHON_VIRTUALENV_HOME/bin/pip install poetry==${POETRY_VERSION}
|
|
|
|
ENV PATH="$PYTHON_VIRTUALENV_HOME/bin:$PATH" \
|
|
VIRTUAL_ENV=$PYTHON_VIRTUALENV_HOME
|
|
|
|
# Setup for bash
|
|
RUN poetry completions bash >> /home/vscode/.bash_completion && \
|
|
echo "export PATH=$PYTHON_VIRTUALENV_HOME/bin:$PATH" >> ~/.bashrc
|
|
|
|
# Set the working directory for the app
|
|
WORKDIR /workspaces/langchain
|
|
|
|
# Use a multi-stage build to install dependencies
|
|
FROM langchain-dev-base AS langchain-dev-dependencies
|
|
|
|
ARG PYTHON_VIRTUALENV_HOME
|
|
|
|
# Copy only the dependency files for installation
|
|
COPY pyproject.toml poetry.toml ./
|
|
|
|
# Install the Poetry dependencies (this layer will be cached as long as the dependencies don't change)
|
|
RUN poetry install --no-interaction --no-ansi --with dev,test,docs |