From 95ebe372df237f29cdc593eeab7695de07be3b1d Mon Sep 17 00:00:00 2001 From: seavphing Date: Wed, 16 Oct 2024 22:35:07 +0700 Subject: [PATCH 1/2] improve Dockerfile to use entrypoint in order to get better log when receive any request --- Dockerfile | 3 ++- entrypoint.sh | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index d85d5bc..1da43d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,4 +55,5 @@ ENV PYTHONUNBUFFERED=1 # run the app (re-configure port if necessary) WORKDIR /app/deepface/api/src EXPOSE 5000 -CMD ["gunicorn", "--workers=1", "--timeout=3600", "--bind=0.0.0.0:5000", "app:create_app()"] +# CMD ["gunicorn", "--workers=1", "--timeout=3600", "--bind=0.0.0.0:5000", "app:create_app()"] +ENTRYPOINT [ "sh", "entrypoint.sh" ] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..8b3ef43 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1 @@ +gunicorn -w 1 -b 0.0.0.0:5000 --timeout 7200 --log-level 'debug' --access-logfile - --access-logformat '%(h)s - - [%(t)s] "%(r)s" %(s)s %(b)s %(L)s' app:create_app() \ No newline at end of file From 9c5981f8a64f39b905010ed00b8e4f8feb3dee33 Mon Sep 17 00:00:00 2001 From: seavphing Date: Thu, 17 Oct 2024 10:24:56 +0700 Subject: [PATCH 2/2] correct docker file and improve requirements.txt file to use the workable tensorflow version --- Dockerfile | 12 ++++++++++-- entrypoint.sh | 6 +++++- requirements_local | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1da43d8..9217aeb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,14 +7,21 @@ LABEL org.opencontainers.image.source https://github.com/serengil/deepface RUN mkdir /app RUN mkdir /app/deepface + + # ----------------------------------- # switch to application directory WORKDIR /app # ----------------------------------- # update image os -RUN apt-get update -RUN apt-get install ffmpeg libsm6 libxext6 -y +# Install system dependencies +RUN apt-get update && apt-get install -y \ + ffmpeg \ + libsm6 \ + libxext6 \ + libhdf5-dev \ + && rm -rf /var/lib/apt/lists/* # ----------------------------------- # Copy required files from repo into image @@ -25,6 +32,7 @@ COPY ./requirements_local /app/requirements_local.txt COPY ./package_info.json /app/ COPY ./setup.py /app/ COPY ./README.md /app/ +COPY ./entrypoint.sh /app/deepface/api/src/entrypoint.sh # ----------------------------------- # if you plan to use a GPU, you should install the 'tensorflow-gpu' package diff --git a/entrypoint.sh b/entrypoint.sh index 8b3ef43..b31c2b2 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1 +1,5 @@ -gunicorn -w 1 -b 0.0.0.0:5000 --timeout 7200 --log-level 'debug' --access-logfile - --access-logformat '%(h)s - - [%(t)s] "%(r)s" %(s)s %(b)s %(L)s' app:create_app() \ No newline at end of file +# Example content +echo "Starting the application..." +exec "$@" + +gunicorn -w 1 -b 0.0.0.0:5000 --timeout 7200 --log-level 'debug' --access-logfile - --access-logformat '%(h)s - - [%(t)s] "%(r)s" %(s)s %(b)s %(L)s' app:create_app \ No newline at end of file diff --git a/requirements_local b/requirements_local index e869c3f..22bbe11 100644 --- a/requirements_local +++ b/requirements_local @@ -2,5 +2,5 @@ numpy==1.22.3 pandas==2.0.3 Pillow==9.0.0 opencv-python==4.9.0.80 -tensorflow==2.9.0 -keras==2.9.0 +tensorflow==2.13.1 +keras==2.13.1