diff --git a/.env b/.env index b05dac68..c5248593 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 52869bb9..27ab3800 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 3a4cbb95..4dab7d9c 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 aab14205..e7390e56 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