From 1a7587ee485f81fedb6616db8d6f982a27cdbd45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Prud=27homme?= Date: Thu, 18 May 2023 19:18:32 +0200 Subject: [PATCH] feat: add an environment variable to manage rebuild in Docker image (#290) Co-authored-by: Ettore Di Giacinto --- .env | 1 + Dockerfile | 3 ++- README.md | 2 ++ entrypoint.sh | 4 +++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.env b/.env index b05dac6..c524859 100644 --- a/.env +++ b/.env @@ -3,3 +3,4 @@ MODELS_PATH=/models # DEBUG=true # BUILD_TYPE=generic +# REBUILD=true diff --git a/Dockerfile b/Dockerfile index 52869bb..27ab380 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,11 @@ ARG GO_VERSION=1.20 ARG BUILD_TYPE= FROM golang:$GO_VERSION +ENV REBUILD=true WORKDIR /build RUN apt-get update && apt-get install -y cmake libgomp1 libopenblas-dev libopenblas-base libopencv-dev libopencv-core-dev libopencv-core4.5 COPY . . RUN ln -s /usr/include/opencv4/opencv2/ /usr/include/opencv2 -RUN make prepare-sources +RUN make build EXPOSE 8080 ENTRYPOINT [ "/build/entrypoint.sh" ] diff --git a/README.md b/README.md index 3a4cbb9..4dab7d9 100644 --- a/README.md +++ b/README.md @@ -464,6 +464,8 @@ You should see: └───────────────────────────────────────────────────┘ ``` +Note: the binary inside the image is rebuild at the start of the container to enable CPU optimizations for the execution environment, you can set the environment variable `REBUILD` to `false` to prevent this behavior. + ### Build locally diff --git a/entrypoint.sh b/entrypoint.sh index aab1420..e7390e5 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,6 +2,8 @@ cd /build -make build +if [ "$REBUILD" != "false" ]; then + make rebuild +fi ./local-ai "$@" \ No newline at end of file