|
1 | 1 | ARG GO_VERSION=1.20 |
2 | | -FROM golang:$GO_VERSION |
| 2 | + |
| 3 | +FROM golang:$GO_VERSION as builder |
3 | 4 |
|
4 | 5 | ARG BUILD_TYPE= |
5 | 6 | ARG GO_TAGS= |
@@ -41,6 +42,53 @@ RUN apt-get install -y libopencv-dev && \ |
41 | 42 | COPY . . |
42 | 43 | RUN make build |
43 | 44 |
|
| 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 | + |
44 | 92 | # Define the health check command |
45 | 93 | HEALTHCHECK --interval=1m --timeout=10m --retries=10 \ |
46 | 94 | CMD curl -f $HEALTHCHECK_ENDPOINT || exit 1 |
|
0 commit comments