Skip to content

Commit

Permalink
Create an small size image (#227)
Browse files Browse the repository at this point in the history
* feat: change engine classe in order to use it with directory

* feat: create a light Dockerfile image

* feat: Engine refactor for ETL

* make style

* refactor

* revert ETL part

* engine.py from main

* update-new-datamodel is the source

---------

Co-authored-by: Ronan <ronan_2@hotmail.com>
Co-authored-by: Ronan <RonanMorgan@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 9, 2024
1 parent 5f17e88 commit 3d20aab
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
*.pyc
__pycache__
*.log
35 changes: 35 additions & 0 deletions Dockerfile-cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM python:3.8.16-slim

# set environment variables
ENV PATH="/usr/local/bin:$PATH"
ENV LANG="C.UTF-8"
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# set work directory
WORKDIR /usr/src/app

COPY ./setup.py /tmp/setup.py

# install git
RUN apt-get update && apt-get install git -y

RUN apt-get install ffmpeg libsm6 libxext6 -y\
&& pip install --upgrade --no-cache-dir pip setuptools wheel

RUN pip install --no-cache-dir torch==2.3.1+cpu torchvision==0.18.1+cpu -f https://download.pytorch.org/whl/torch_stable.html

COPY ./src/requirements-light.txt /tmp/requirements.txt
RUN pip install --default-timeout=500 -r /tmp/requirements.txt \
&& pip cache purge \
&& rm -rf /root/.cache/pip

RUN pip install --no-cache-dir git+https://github.com/pyronear/pyro-api.git@92b9e28fe4b329aa28c7833b28f3bc89ab1b756c#subdirectory=client

COPY ./pyroengine /tmp/pyroengine

RUN pip install -e /tmp/. \
&& pip cache purge \
&& rm -rf /root/.cache/pip

COPY ./src/run.py /usr/src/app/run.py
COPY ./src/control_reolink_cam.py /usr/src/app/control_reolink_cam.py
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ lock:
cd src; poetry export -f requirements.txt --without-hashes --output requirements.txt

# Build the docker
build-app:
$(info if you need to update the client change the hash in the .toml and use make lock before)
build-gpu-app:
$(info If you need to update the client change the hash in the .toml and use make lock before)
docker build . -t pyronear/pyro-engine:latest

# Build the light docker
build-cpu-app:
$(info The pyro-client version is hardcoded in the Dockerfile)
docker build . -t pyronear/pyro-engine:latest -f Dockerfile-cpu

build-lib:
pip install -e .
python setup.py sdist bdist_wheel

build-optional-lib:
pip install -e .[test]
Expand Down
10 changes: 10 additions & 0 deletions src/requirements-light.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
python-dotenv==1.0.1 ; python_version >= "3.8" and python_version < "4.0"
coloredlogs==15.0.1 ; python_version >= "3.8" and python_version < "4.0"
flatbuffers==24.3.25 ; python_version >= "3.8" and python_version < "4.0"
humanfriendly==10.0 ; python_version >= "3.8" and python_version < "4.0"
onnx==1.17.0 ; python_version >= "3.8" and python_version < "4.0"
onnxruntime==1.19.2 ; python_version >= "3.8" and python_version < "4.0"
protobuf==5.28.2 ; python_version >= "3.8" and python_version < "4.0"

huggingface-hub==0.24.6 ; python_version >= "3.8" and python_version < "4"
ultralytics==8.2.50 ; python_version >= "3.8" and python_version < "4.0"

0 comments on commit 3d20aab

Please sign in to comment.