Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: reduce memory consumption and dockerfile size #2578

Merged
merged 15 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading