From 390ff2bcfd26cec5d8c3ed7c263ecb166816dba4 Mon Sep 17 00:00:00 2001 From: Lingyi Zhang Date: Fri, 13 Sep 2024 12:16:05 -0400 Subject: [PATCH] [Tidy] Reduce the image size of UI for chart (#701) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- ..._lingyi_zhang_build_for_amd64_and_arm64.md | 48 ++++++++++++ vizro-ai/examples/dashboard_ui/.dockerignore | 41 ++++++++++ vizro-ai/examples/dashboard_ui/Dockerfile | 33 ++++++-- .../examples/dashboard_ui/requirements.txt | 75 +++++++++---------- 4 files changed, 149 insertions(+), 48 deletions(-) create mode 100644 vizro-ai/changelog.d/20240912_211749_lingyi_zhang_build_for_amd64_and_arm64.md create mode 100644 vizro-ai/examples/dashboard_ui/.dockerignore diff --git a/vizro-ai/changelog.d/20240912_211749_lingyi_zhang_build_for_amd64_and_arm64.md b/vizro-ai/changelog.d/20240912_211749_lingyi_zhang_build_for_amd64_and_arm64.md new file mode 100644 index 000000000..f1f65e73c --- /dev/null +++ b/vizro-ai/changelog.d/20240912_211749_lingyi_zhang_build_for_amd64_and_arm64.md @@ -0,0 +1,48 @@ + + + + + + + + + diff --git a/vizro-ai/examples/dashboard_ui/.dockerignore b/vizro-ai/examples/dashboard_ui/.dockerignore new file mode 100644 index 000000000..aa3169331 --- /dev/null +++ b/vizro-ai/examples/dashboard_ui/.dockerignore @@ -0,0 +1,41 @@ +# Git +.git +.gitignore +.gitattributes + +# Docker +Dockerfile +docker-compose.yml +.dockerignore + +# Python +*.pyc +*.pyo +*.pyd +__pycache__ +.pytest_cache +.coverage +htmlcov/ +.tox/ +.venv +venv/ +*.egg-info/ +dist/ +build/ + +# Editors +.vscode/ +.idea/ +*.swp +*.swo + +# OS generated +.DS_Store +Thumbs.db + +# Application specific +*.log +*.sqlite3 + +# csv +*.csv diff --git a/vizro-ai/examples/dashboard_ui/Dockerfile b/vizro-ai/examples/dashboard_ui/Dockerfile index a09ba3aef..489ae37e8 100644 --- a/vizro-ai/examples/dashboard_ui/Dockerfile +++ b/vizro-ai/examples/dashboard_ui/Dockerfile @@ -1,17 +1,36 @@ -# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker -# you will also find guides on how best to write your Dockerfile +FROM python:3.12-slim AS builder -FROM python:3.12 +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + && rm -rf /var/lib/apt/lists/* RUN useradd -m -u 1000 user +USER user +ENV HOME=/home/user \ + PATH=/home/user/.local/bin:$PATH +WORKDIR $HOME/app -WORKDIR /app +COPY --chown=user requirements.txt . +RUN pip install --user --no-cache-dir --upgrade pip && \ + pip install --user --no-cache-dir -r requirements.txt -COPY --chown=user ./requirements.txt requirements.txt +# Production stage +FROM python:3.12-slim -RUN pip install --no-cache-dir --upgrade -r requirements.txt +RUN apt-get update && apt-get upgrade -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* -COPY --chown=user . /app +RUN useradd -m -u 1000 user +USER user +ENV HOME=/home/user \ + PATH=/home/user/.local/bin:$PATH +WORKDIR $HOME/app + +COPY --from=builder --chown=user $HOME/.local/lib/python3.12/site-packages $HOME/.local/lib/python3.12/site-packages +COPY --from=builder --chown=user $HOME/.local/bin $HOME/.local/bin + +COPY --chown=user . $HOME/app EXPOSE 7860 diff --git a/vizro-ai/examples/dashboard_ui/requirements.txt b/vizro-ai/examples/dashboard_ui/requirements.txt index 4a932b3b0..85efd986b 100644 --- a/vizro-ai/examples/dashboard_ui/requirements.txt +++ b/vizro-ai/examples/dashboard_ui/requirements.txt @@ -42,12 +42,12 @@ blinker==1.8.2 # via flask cachelib==0.9.0 # via flask-caching -certifi==2024.7.4 +certifi==2024.8.30 # via # httpcore # httpx # requests -cffi==1.17.0 +cffi==1.17.1 # via argon2-cffi-bindings charset-normalizer==3.3.2 # via requests @@ -59,7 +59,7 @@ comm==0.2.2 # via # ipykernel # ipywidgets -dash==2.17.1 +dash==2.18.1 # via # dash-ag-grid # dash-bootstrap-components @@ -84,7 +84,7 @@ defusedxml==0.7.1 # via nbconvert distro==1.9.0 # via openai -executing==2.0.1 +executing==2.1.0 # via stack-data fastjsonschema==2.20.0 # via nbformat @@ -100,6 +100,8 @@ frozenlist==1.4.1 # via # aiohttp # aiosignal +greenlet==3.1.0 + # via sqlalchemy gunicorn==23.0.0 # via -r requirements.in h11==0.14.0 @@ -118,15 +120,14 @@ idna==3.8 # jsonschema # requests # yarl -importlib-metadata==8.4.0 +importlib-metadata==8.5.0 # via dash ipykernel==6.29.5 # via # jupyter # jupyter-console # jupyterlab - # qtconsole -ipython==8.26.0 +ipython==8.27.0 # via # ipykernel # ipywidgets @@ -163,7 +164,7 @@ jsonschema==4.23.0 # nbformat jsonschema-specifications==2023.12.1 # via jsonschema -jupyter==1.0.0 +jupyter==1.1.1 # via -r requirements.in jupyter-client==8.6.2 # via @@ -171,7 +172,6 @@ jupyter-client==8.6.2 # jupyter-console # jupyter-server # nbclient - # qtconsole jupyter-console==6.6.3 # via jupyter jupyter-core==5.7.2 @@ -184,7 +184,6 @@ jupyter-core==5.7.2 # nbclient # nbconvert # nbformat - # qtconsole jupyter-events==0.10.0 # via jupyter-server jupyter-lsp==2.2.5 @@ -199,7 +198,9 @@ jupyter-server==2.14.2 jupyter-server-terminals==0.5.3 # via jupyter-server jupyterlab==4.2.5 - # via notebook + # via + # jupyter + # notebook jupyterlab-pygments==0.3.0 # via nbconvert jupyterlab-server==2.27.3 @@ -208,9 +209,9 @@ jupyterlab-server==2.27.3 # notebook jupyterlab-widgets==3.0.13 # via ipywidgets -langchain==0.2.15 +langchain==0.2.16 # via vizro-ai -langchain-core==0.2.36 +langchain-core==0.2.39 # via # langchain # langchain-openai @@ -219,13 +220,13 @@ langchain-core==0.2.36 # langgraph-checkpoint langchain-openai==0.1.23 # via vizro-ai -langchain-text-splitters==0.2.2 +langchain-text-splitters==0.2.4 # via langchain -langgraph==0.2.14 +langgraph==0.2.16 # via vizro-ai -langgraph-checkpoint==1.0.6 +langgraph-checkpoint==1.0.9 # via langgraph -langsmith==0.1.106 +langsmith==0.1.119 # via # langchain # langchain-core @@ -240,7 +241,7 @@ matplotlib-inline==0.1.7 # ipython mistune==3.0.2 # via nbconvert -multidict==6.0.5 +multidict==6.1.0 # via # aiohttp # yarl @@ -271,7 +272,7 @@ numpy==1.26.4 # via # langchain # pandas -openai==1.42.0 +openai==1.45.0 # via # langchain-openai # vizro-ai @@ -290,8 +291,6 @@ packaging==24.1 # langchain-core # nbconvert # plotly - # qtconsole - # qtpy pandas==2.2.2 # via # vizro @@ -304,11 +303,11 @@ pathspec==0.12.1 # via black pexpect==4.9.0 # via ipython -platformdirs==4.2.2 +platformdirs==4.3.2 # via # black # jupyter-core -plotly==5.23.0 +plotly==5.24.1 # via dash prometheus-client==0.20.0 # via jupyter-server @@ -326,21 +325,20 @@ pure-eval==0.2.3 # via stack-data pycparser==2.22 # via cffi -pydantic==2.8.2 +pydantic==2.9.1 # via # langchain # langchain-core # langsmith # openai # vizro -pydantic-core==2.20.1 +pydantic-core==2.23.3 # via pydantic pygments==2.18.0 # via # ipython # jupyter-console # nbconvert - # qtconsole python-dateutil==2.9.0.post0 # via # arrow @@ -350,7 +348,7 @@ python-dotenv==1.0.1 # via vizro-ai python-json-logger==2.0.7 # via jupyter-events -pytz==2024.1 +pytz==2024.2 # via pandas pyyaml==6.0.2 # via @@ -363,16 +361,12 @@ pyzmq==26.2.0 # jupyter-client # jupyter-console # jupyter-server -qtconsole==5.6.0 - # via jupyter -qtpy==2.4.1 - # via qtconsole referencing==0.35.1 # via # jsonschema # jsonschema-specifications # jupyter-events -regex==2024.7.24 +regex==2024.9.11 # via tiktoken requests==2.32.3 # via @@ -395,11 +389,11 @@ rpds-py==0.20.0 # via # jsonschema # referencing -ruff==0.6.2 +ruff==0.6.4 # via vizro send2trash==1.8.3 # via jupyter-server -setuptools==74.0.0 +setuptools==74.1.2 # via # dash # jupyterlab @@ -417,7 +411,7 @@ sniffio==1.3.1 # openai soupsieve==2.6 # via beautifulsoup4 -sqlalchemy==2.0.32 +sqlalchemy==2.0.34 # via langchain stack-data==0.6.3 # via ipython @@ -462,8 +456,7 @@ traitlets==5.14.3 # nbclient # nbconvert # nbformat - # qtconsole -types-python-dateutil==2.9.0.20240821 +types-python-dateutil==2.9.0.20240906 # via arrow typing-extensions==4.12.2 # via @@ -477,11 +470,11 @@ tzdata==2024.1 # via pandas uri-template==1.3.0 # via jsonschema -urllib3==2.2.2 +urllib3==2.2.3 # via requests -vizro==0.1.21 +vizro==0.1.23 # via vizro-ai -vizro-ai==0.2.1 +vizro-ai==0.2.3 # via -r requirements.in wcwidth==0.2.13 # via prompt-toolkit @@ -501,7 +494,7 @@ widgetsnbextension==4.0.13 # via ipywidgets wrapt==1.16.0 # via vizro -yarl==1.9.4 +yarl==1.11.1 # via aiohttp zipp==3.20.1 # via importlib-metadata