Skip to content

Commit 6d71dd7

Browse files
authored
fix: do not build from the same container (#434)
Signed-off-by: mudler <[email protected]>
1 parent 49ce249 commit 6d71dd7

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

Dockerfile

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
ARG GO_VERSION=1.20
2-
FROM golang:$GO_VERSION
2+
3+
FROM golang:$GO_VERSION as builder
34

45
ARG BUILD_TYPE=
56
ARG GO_TAGS=
@@ -41,6 +42,53 @@ RUN apt-get install -y libopencv-dev && \
4142
COPY . .
4243
RUN make build
4344

45+
FROM golang:$GO_VERSION
46+
47+
ARG BUILD_TYPE=
48+
ARG GO_TAGS=
49+
ARG CUDA_MAJOR_VERSION=11
50+
ARG CUDA_MINOR_VERSION=7
51+
52+
ENV BUILD_TYPE=${BUILD_TYPE}
53+
ENV GO_TAGS=${GO_TAGS}
54+
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
55+
ENV NVIDIA_REQUIRE_CUDA="cuda>=${CUDA_MAJOR_VERSION}.0"
56+
ENV NVIDIA_VISIBLE_DEVICES=all
57+
ENV HEALTHCHECK_ENDPOINT=http://localhost:8080/readyz
58+
ENV HEALTHCHECK_TIMEOUT=10m
59+
ENV HEALTHCHECK_INTERVAL=10m
60+
ENV HEALTHCHECK_RETRIES=10m
61+
62+
ENV REBUILD=true
63+
64+
WORKDIR /build
65+
66+
RUN apt-get update && \
67+
apt-get install -y ca-certificates cmake curl
68+
69+
# CuBLAS requirements
70+
RUN if [ "${BUILD_TYPE}" = "cublas" ]; then \
71+
apt-get install -y software-properties-common && \
72+
apt-add-repository contrib && \
73+
curl -O https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.0-1_all.deb && \
74+
dpkg -i cuda-keyring_1.0-1_all.deb && \
75+
rm -f cuda-keyring_1.0-1_all.deb && \
76+
apt-get update && \
77+
apt-get install -y cuda-nvcc-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} libcublas-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
78+
; fi
79+
ENV PATH /usr/local/cuda/bin:${PATH}
80+
81+
# OpenBLAS requirements
82+
RUN apt-get install -y libopenblas-dev
83+
84+
# Stable Diffusion requirements
85+
RUN apt-get install -y libopencv-dev && \
86+
ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
87+
88+
COPY . .
89+
RUN make prepare-sources
90+
COPY --from=builder /build/local-ai ./
91+
4492
# Define the health check command
4593
HEALTHCHECK --interval=1m --timeout=10m --retries=10 \
4694
CMD curl -f $HEALTHCHECK_ENDPOINT || exit 1

entrypoint.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/bin/bash
2+
set -e
23

34
cd /build
45

56
if [ "$REBUILD" != "false" ]; then
6-
make rebuild
7+
rm -rf ./local-ai
8+
make build
79
fi
810

911
./local-ai "$@"

0 commit comments

Comments
 (0)