🐛 fix(Dockerfile): copy only necessary file to avoid unnecessary image rebuilding

 feat(Dockerfile): add support for copying app code and tests to the image to ensure they are included in the deployment
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-09-22 10:46:01 -03:00
commit d4f3640e5f
2 changed files with 15 additions and 4 deletions

View file

@ -83,9 +83,15 @@ WORKDIR $PYSETUP_PATH
COPY --from=builder-base $POETRY_HOME $POETRY_HOME
COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH
COPY ./src/backend ./src/backend
COPY ./tests ./tests
# Copy just one file to avoid rebuilding the whole image
COPY ./src/backend/langflow/__init__.py ./src/backend/langflow/__init__.py
# quicker install as runtime deps are already installed
RUN --mount=type=cache,target=/root/.cache \
poetry install --with=dev --extras deploy
# copy in our app code
COPY ./src/backend ./src/backend
RUN --mount=type=cache,target=/root/.cache \
poetry install --with=dev --extras deploy
COPY ./tests ./tests=

View file

@ -81,7 +81,12 @@ WORKDIR $PYSETUP_PATH
COPY --from=builder-base $POETRY_HOME $POETRY_HOME
COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH
COPY ./src/backend ./src/backend
# Copy just one file to avoid rebuilding the whole image
COPY ./src/backend/langflow/__init__.py ./src/backend/langflow/__init__.py
# quicker install as runtime deps are already installed
RUN --mount=type=cache,target=/root/.cache \
poetry install --with=dev --extras deploy
# copy in our app code
COPY ./src/backend ./src/backend
COPY ./tests ./tests