2023-06-18 06:27:29 +00:00
|
|
|
ARG GO_VERSION=1.20-bullseye
|
2023-05-30 13:53:37 +00:00
|
|
|
|
2023-06-13 06:39:38 +00:00
|
|
|
FROM golang:$GO_VERSION as requirements
|
2023-05-29 21:12:27 +00:00
|
|
|
|
2023-06-13 06:39:38 +00:00
|
|
|
ARG BUILD_TYPE
|
2023-05-29 21:12:27 +00:00
|
|
|
ARG CUDA_MAJOR_VERSION=11
|
|
|
|
ARG CUDA_MINOR_VERSION=7
|
|
|
|
|
|
|
|
ENV BUILD_TYPE=${BUILD_TYPE}
|
|
|
|
|
|
|
|
RUN apt-get update && \
|
2023-06-18 06:27:29 +00:00
|
|
|
apt-get install -y ca-certificates cmake curl patch
|
2023-05-29 21:12:27 +00:00
|
|
|
|
|
|
|
# CuBLAS requirements
|
|
|
|
RUN if [ "${BUILD_TYPE}" = "cublas" ]; then \
|
|
|
|
apt-get install -y software-properties-common && \
|
|
|
|
apt-add-repository contrib && \
|
|
|
|
curl -O https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.0-1_all.deb && \
|
|
|
|
dpkg -i cuda-keyring_1.0-1_all.deb && \
|
|
|
|
rm -f cuda-keyring_1.0-1_all.deb && \
|
|
|
|
apt-get update && \
|
|
|
|
apt-get install -y cuda-nvcc-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} libcublas-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
|
|
|
|
; fi
|
|
|
|
ENV PATH /usr/local/cuda/bin:${PATH}
|
|
|
|
|
|
|
|
# OpenBLAS requirements
|
|
|
|
RUN apt-get install -y libopenblas-dev
|
|
|
|
|
|
|
|
# Stable Diffusion requirements
|
|
|
|
RUN apt-get install -y libopencv-dev && \
|
|
|
|
ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
|
|
|
|
|
2023-06-13 06:39:38 +00:00
|
|
|
FROM requirements as builder
|
2023-05-30 13:53:37 +00:00
|
|
|
|
2023-06-02 06:53:45 +00:00
|
|
|
ARG GO_TAGS=stablediffusion
|
2023-05-30 13:53:37 +00:00
|
|
|
|
|
|
|
ENV GO_TAGS=${GO_TAGS}
|
|
|
|
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
|
|
|
|
ENV NVIDIA_REQUIRE_CUDA="cuda>=${CUDA_MAJOR_VERSION}.0"
|
|
|
|
ENV NVIDIA_VISIBLE_DEVICES=all
|
|
|
|
|
|
|
|
WORKDIR /build
|
|
|
|
|
2023-06-13 06:39:38 +00:00
|
|
|
COPY . .
|
|
|
|
RUN make build
|
2023-05-30 13:53:37 +00:00
|
|
|
|
2023-06-13 06:39:38 +00:00
|
|
|
FROM requirements
|
|
|
|
|
|
|
|
ARG FFMPEG
|
|
|
|
|
|
|
|
ENV REBUILD=true
|
|
|
|
ENV HEALTHCHECK_ENDPOINT=http://localhost:8080/readyz
|
2023-06-04 12:00:21 +00:00
|
|
|
|
|
|
|
# Add FFmpeg
|
|
|
|
RUN if [ "${FFMPEG}" = "true" ]; then \
|
|
|
|
apt-get install -y ffmpeg \
|
|
|
|
; fi
|
|
|
|
|
2023-06-13 06:39:38 +00:00
|
|
|
WORKDIR /build
|
2023-05-30 13:53:37 +00:00
|
|
|
|
2023-06-17 21:22:04 +00:00
|
|
|
COPY . .
|
|
|
|
RUN make prepare-sources
|
2023-05-30 13:53:37 +00:00
|
|
|
COPY --from=builder /build/local-ai ./
|
|
|
|
|
2023-05-26 16:34:02 +00:00
|
|
|
# Define the health check command
|
2023-05-30 10:00:30 +00:00
|
|
|
HEALTHCHECK --interval=1m --timeout=10m --retries=10 \
|
2023-05-26 16:34:02 +00:00
|
|
|
CMD curl -f $HEALTHCHECK_ENDPOINT || exit 1
|
2023-05-29 21:12:27 +00:00
|
|
|
|
2023-04-27 16:45:24 +00:00
|
|
|
EXPOSE 8080
|
2023-06-18 06:27:29 +00:00
|
|
|
ENTRYPOINT [ "/build/entrypoint.sh" ]
|