feat: add an environment variable to manage rebuild in Docker image (#290)

Co-authored-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
This commit is contained in:
Sébastien Prud'homme 2023-05-18 19:18:32 +02:00 committed by GitHub
parent cc9aa9eb3f
commit 1a7587ee48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 2 deletions

1
.env
View File

@ -3,3 +3,4 @@
MODELS_PATH=/models MODELS_PATH=/models
# DEBUG=true # DEBUG=true
# BUILD_TYPE=generic # BUILD_TYPE=generic
# REBUILD=true

View File

@ -1,10 +1,11 @@
ARG GO_VERSION=1.20 ARG GO_VERSION=1.20
ARG BUILD_TYPE= ARG BUILD_TYPE=
FROM golang:$GO_VERSION FROM golang:$GO_VERSION
ENV REBUILD=true
WORKDIR /build WORKDIR /build
RUN apt-get update && apt-get install -y cmake libgomp1 libopenblas-dev libopenblas-base libopencv-dev libopencv-core-dev libopencv-core4.5 RUN apt-get update && apt-get install -y cmake libgomp1 libopenblas-dev libopenblas-base libopencv-dev libopencv-core-dev libopencv-core4.5
COPY . . COPY . .
RUN ln -s /usr/include/opencv4/opencv2/ /usr/include/opencv2 RUN ln -s /usr/include/opencv4/opencv2/ /usr/include/opencv2
RUN make prepare-sources RUN make build
EXPOSE 8080 EXPOSE 8080
ENTRYPOINT [ "/build/entrypoint.sh" ] ENTRYPOINT [ "/build/entrypoint.sh" ]

View File

@ -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.
</details> </details>
### Build locally ### Build locally

View File

@ -2,6 +2,8 @@
cd /build cd /build
make build if [ "$REBUILD" != "false" ]; then
make rebuild
fi
./local-ai "$@" ./local-ai "$@"