Skip to content

Commit

Permalink
chore: reduce memory consumption and dockerfile size (#2578)
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren authored Nov 25, 2024
1 parent 00c0f79 commit bdc8e52
Show file tree
Hide file tree
Showing 29 changed files with 289 additions and 1,976 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,4 @@ ee/experimental/ai_temp/*
oauth2.cfg
scripts/keep_slack_bot.py
keepnew.db
providers_cache.json
22 changes: 14 additions & 8 deletions docker/Dockerfile.api
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11.6-slim as base
FROM python:3.11.10-slim-bullseye as base

ENV PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
Expand All @@ -17,25 +17,31 @@ ENV PIP_DEFAULT_TIMEOUT=100 \
RUN pip install "poetry==$POETRY_VERSION"
RUN python -m venv /venv
COPY pyproject.toml poetry.lock ./
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes && /venv/bin/python -m pip install --upgrade -r requirements.txt
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes --only main && \
/venv/bin/python -m pip install --upgrade -r requirements.txt && \
pip uninstall -y poetry
COPY keep keep
COPY ee keep/ee
COPY examples examples
COPY README.md README.md
RUN poetry build && /venv/bin/pip install --use-deprecated=legacy-resolver dist/*.whl
RUN /venv/bin/pip install --use-deprecated=legacy-resolver . && \
rm -rf /root/.cache/pip && \
find /venv -type d -name "__pycache__" -exec rm -r {} + && \
find /venv -type f -name "*.pyc" -delete

FROM base as final
ENV PATH="/venv/bin:${PATH}"
ENV VIRTUAL_ENV="/venv"
ENV EE_PATH="ee"
COPY --from=builder /venv /venv
COPY --from=builder /app/examples /examples
# Build the providers cache
RUN keep provider build_cache
# as per Openshift guidelines, https://docs.openshift.com/container-platform/4.11/openshift_images/create-images.html#use-uid_create-images
RUN chgrp -R 0 /app && chmod -R g=u /app
RUN chown -R keep:keep /app
RUN chown -R keep:keep /venv
RUN chgrp -R 0 /app && chmod -R g=u /app && \
chown -R keep:keep /app && \
chown -R keep:keep /venv
USER keep

ENTRYPOINT ["/venv/lib/python3.11/site-packages/keep/entrypoint.sh"]

CMD ["gunicorn", "keep.api.api:get_app", "--bind" , "0.0.0.0:8080" , "--workers", "4" , "-k" , "uvicorn.workers.UvicornWorker", "-c", "/venv/lib/python3.11/site-packages/keep/api/config.py"]
CMD ["gunicorn", "keep.api.api:get_app", "--bind" , "0.0.0.0:8080" , "--workers", "4" , "-k" , "uvicorn.workers.UvicornWorker", "-c", "/venv/lib/python3.11/site-packages/keep/api/config.py", "--preload"]
Empty file removed ee/experimental/__init__.py
Empty file.
Empty file removed ee/experimental/ai_temp/.gitkeep
Empty file.
239 changes: 0 additions & 239 deletions ee/experimental/generative_utils.py

This file was deleted.

106 changes: 0 additions & 106 deletions ee/experimental/graph_utils.py

This file was deleted.

Loading

0 comments on commit bdc8e52

Please sign in to comment.