@@ -8,7 +8,7 @@ FROM ${BASE_IMAGE} AS requirements-core
88
99USER root
1010
11- ARG GO_VERSION=1.22.5
11+ ARG GO_VERSION=1.22.6
1212ARG TARGETARCH
1313ARG TARGETVARIANT
1414
@@ -30,7 +30,7 @@ RUN apt-get update && \
3030
3131# Install Go
3232RUN curl -L -s https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz | tar -C /usr/local -xz
33- ENV PATH $PATH:/root/go/bin:/usr/local/go/bin
33+ ENV PATH= $PATH:/root/go/bin:/usr/local/go/bin
3434
3535# Install grpc compilers
3636RUN go install google.golang.org/protobuf/cmd/
[email protected] && \
@@ -39,15 +39,18 @@ RUN go install google.golang.org/protobuf/cmd/
[email protected] && \
3939COPY --chmod=644 custom-ca-certs/* /usr/local/share/ca-certificates/
4040RUN update-ca-certificates
4141
42+ RUN test -n "$TARGETARCH" \
43+ || (echo 'warn: missing $TARGETARCH, either set this `ARG` manually, or run using `docker buildkit`' )
44+
4245# Use the variables in subsequent instructions
4346RUN echo "Target Architecture: $TARGETARCH"
4447RUN echo "Target Variant: $TARGETVARIANT"
4548
4649# Cuda
47- ENV PATH /usr/local/cuda/bin:${PATH}
50+ ENV PATH= /usr/local/cuda/bin:${PATH}
4851
4952# HipBLAS requirements
50- ENV PATH /opt/rocm/bin:${PATH}
53+ ENV PATH= /opt/rocm/bin:${PATH}
5154
5255# OpenBLAS requirements and stable diffusion
5356RUN apt-get update && \
@@ -62,9 +65,6 @@ RUN ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
6265
6366WORKDIR /build
6467
65- RUN test -n "$TARGETARCH" \
66- || (echo 'warn: missing $TARGETARCH, either set this `ARG` manually, or run using `docker buildkit`' )
67-
6868# ##################################
6969# ##################################
7070
@@ -217,28 +217,27 @@ RUN git clone --recurse-submodules --jobs 4 -b ${GRPC_VERSION} --depth 1 --shall
217217# ##################################
218218# ##################################
219219
220- # The builder target compiles LocalAI. This target is not the target that will be uploaded to the registry.
221- # Adjustments to the build process should likely be made here.
222- FROM requirements-drivers AS builder
220+ # The builder-base target has the arguments, variables, and copies shared between full builder images and the uncompiled devcontainer
221+
222+ FROM requirements-drivers AS builder-base
223223
224224ARG GO_TAGS="stablediffusion tts p2p"
225225ARG GRPC_BACKENDS
226226ARG MAKEFLAGS
227+ ARG LD_FLAGS="-s -w"
227228
228229ENV GRPC_BACKENDS=${GRPC_BACKENDS}
229230ENV GO_TAGS=${GO_TAGS}
230231ENV MAKEFLAGS=${MAKEFLAGS}
231232ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
232233ENV NVIDIA_REQUIRE_CUDA="cuda>=${CUDA_MAJOR_VERSION}.0"
233234ENV NVIDIA_VISIBLE_DEVICES=all
235+ ENV LD_FLAGS=${LD_FLAGS}
234236
235- WORKDIR /build
237+ RUN echo "GO_TAGS: $GO_TAGS" && echo "TARGETARCH: $TARGETARCH"
236238
237- COPY . .
238- COPY .git .
239- RUN echo "GO_TAGS: $GO_TAGS"
239+ WORKDIR /build
240240
241- RUN make prepare
242241
243242# We need protoc installed, and the version in 22.04 is too old. We will create one as part installing the GRPC build below
244243# but that will also being in a newer version of absl which stablediffusion cannot compile with. This version of protoc is only
@@ -256,6 +255,20 @@ RUN <<EOT bash
256255 fi
257256EOT
258257
258+
259+ # ##################################
260+ # ##################################
261+
262+ # The builder target compiles LocalAI. This target is not the target that will be uploaded to the registry.
263+ # Adjustments to the build process should likely be made here.
264+ FROM builder-base AS builder
265+
266+ COPY . .
267+ COPY .git .
268+
269+ RUN make prepare
270+
271+
259272# stablediffusion does not tolerate a newer version of abseil, build it first
260273RUN GRPC_BACKENDS=backend-assets/grpc/stablediffusion make build
261274
@@ -276,6 +289,33 @@ RUN if [ ! -d "/build/sources/go-piper/piper-phonemize/pi/lib/" ]; then \
276289# ##################################
277290# ##################################
278291
292+ # The devcontainer target is not used on CI. It is a target for developers to use locally -
293+ # rather than copying files it mounts them locally and leaves building to the developer
294+
295+ FROM builder-base AS devcontainer
296+
297+ ARG FFMPEG
298+
299+ COPY --from=grpc /opt/grpc /usr/local
300+
301+ # This is somewhat of a dirty hack as this dev machine has issues with stablediffusion... but it should also speed up devcontainers?
302+ # localai/localai:latest-aio-cpu
303+ COPY --from=builder /build/backend-assets/grpc/stablediffusion /build/backend-assets/grpc/stablediffusion
304+
305+ # Add FFmpeg
306+ RUN if [ "${FFMPEG}" = "true" ]; then \
307+ apt-get update && \
308+ apt-get install -y --no-install-recommends \
309+ ffmpeg && \
310+ apt-get clean && \
311+ rm -rf /var/lib/apt/lists/* \
312+ ; fi
313+
314+ RUN go install github.com/go-delve/delve/cmd/dlv@latest
315+
316+ # ##################################
317+ # ##################################
318+
279319# This is the final target. The result of this target will be the image uploaded to the registry.
280320# If you cannot find a more suitable place for an addition, this layer is a suitable place for it.
281321FROM requirements-drivers
0 commit comments