Dockerfile: unify duplicated requirements into single step (#580)

renovate/github.com-imdario-mergo-1.x
Samuel Maynard 1 year ago committed by GitHub
parent 6306885fe7
commit 27887c74d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 55
      Dockerfile

@ -1,21 +1,12 @@
ARG GO_VERSION=1.20 ARG GO_VERSION=1.20
FROM golang:$GO_VERSION as builder FROM golang:$GO_VERSION as requirements
ARG BUILD_TYPE= ARG BUILD_TYPE
ARG GO_TAGS=stablediffusion
ARG CUDA_MAJOR_VERSION=11 ARG CUDA_MAJOR_VERSION=11
ARG CUDA_MINOR_VERSION=7 ARG CUDA_MINOR_VERSION=7
ENV BUILD_TYPE=${BUILD_TYPE} ENV BUILD_TYPE=${BUILD_TYPE}
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
ENV HEALTHCHECK_ENDPOINT=http://localhost:8080/readyz
ENV REBUILD=true
WORKDIR /build
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y ca-certificates cmake curl apt-get install -y ca-certificates cmake curl
@ -39,55 +30,33 @@ RUN apt-get install -y libopenblas-dev
RUN apt-get install -y libopencv-dev && \ RUN apt-get install -y libopencv-dev && \
ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2 ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
COPY . . FROM requirements as builder
RUN make build
FROM golang:$GO_VERSION
ARG BUILD_TYPE=
ARG GO_TAGS=stablediffusion ARG GO_TAGS=stablediffusion
ARG CUDA_MAJOR_VERSION=11
ARG CUDA_MINOR_VERSION=7
ARG FFMPEG=
ENV BUILD_TYPE=${BUILD_TYPE}
ENV GO_TAGS=${GO_TAGS} ENV GO_TAGS=${GO_TAGS}
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
ENV NVIDIA_REQUIRE_CUDA="cuda>=${CUDA_MAJOR_VERSION}.0" ENV NVIDIA_REQUIRE_CUDA="cuda>=${CUDA_MAJOR_VERSION}.0"
ENV NVIDIA_VISIBLE_DEVICES=all ENV NVIDIA_VISIBLE_DEVICES=all
ENV HEALTHCHECK_ENDPOINT=http://localhost:8080/readyz
ENV REBUILD=true
WORKDIR /build WORKDIR /build
RUN apt-get update && \ COPY . .
apt-get install -y ca-certificates cmake curl RUN make build
# CuBLAS requirements FROM requirements
RUN if [ "${BUILD_TYPE}" = "cublas" ]; then \
apt-get install -y software-properties-common && \ ARG FFMPEG
apt-add-repository contrib && \
curl -O https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.0-1_all.deb && \ ENV REBUILD=true
dpkg -i cuda-keyring_1.0-1_all.deb && \ ENV HEALTHCHECK_ENDPOINT=http://localhost:8080/readyz
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
# Add FFmpeg # Add FFmpeg
RUN if [ "${FFMPEG}" = "true" ]; then \ RUN if [ "${FFMPEG}" = "true" ]; then \
apt-get install -y ffmpeg \ apt-get install -y ffmpeg \
; fi ; fi
ENV PATH /usr/local/cuda/bin:${PATH} WORKDIR /build
# 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
COPY . . COPY . .
RUN make prepare-sources RUN make prepare-sources

Loading…
Cancel
Save