@@ -8,7 +8,7 @@ FROM ${BASE_IMAGE} AS requirements-core
8
8
9
9
USER root
10
10
11
- ARG GO_VERSION=1.22.5
11
+ ARG GO_VERSION=1.22.6
12
12
ARG TARGETARCH
13
13
ARG TARGETVARIANT
14
14
@@ -30,7 +30,7 @@ RUN apt-get update && \
30
30
31
31
# Install Go
32
32
RUN 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
34
34
35
35
# Install grpc compilers
36
36
RUN go install google.golang.org/protobuf/cmd/
[email protected] && \
@@ -39,15 +39,18 @@ RUN go install google.golang.org/protobuf/cmd/
[email protected] && \
39
39
COPY --chmod=644 custom-ca-certs/* /usr/local/share/ca-certificates/
40
40
RUN update-ca-certificates
41
41
42
+ RUN test -n "$TARGETARCH" \
43
+ || (echo 'warn: missing $TARGETARCH, either set this `ARG` manually, or run using `docker buildkit`' )
44
+
42
45
# Use the variables in subsequent instructions
43
46
RUN echo "Target Architecture: $TARGETARCH"
44
47
RUN echo "Target Variant: $TARGETVARIANT"
45
48
46
49
# Cuda
47
- ENV PATH /usr/local/cuda/bin:${PATH}
50
+ ENV PATH= /usr/local/cuda/bin:${PATH}
48
51
49
52
# HipBLAS requirements
50
- ENV PATH /opt/rocm/bin:${PATH}
53
+ ENV PATH= /opt/rocm/bin:${PATH}
51
54
52
55
# OpenBLAS requirements and stable diffusion
53
56
RUN apt-get update && \
@@ -62,9 +65,6 @@ RUN ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
62
65
63
66
WORKDIR /build
64
67
65
- RUN test -n "$TARGETARCH" \
66
- || (echo 'warn: missing $TARGETARCH, either set this `ARG` manually, or run using `docker buildkit`' )
67
-
68
68
# ##################################
69
69
# ##################################
70
70
@@ -217,28 +217,27 @@ RUN git clone --recurse-submodules --jobs 4 -b ${GRPC_VERSION} --depth 1 --shall
217
217
# ##################################
218
218
# ##################################
219
219
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
223
223
224
224
ARG GO_TAGS="stablediffusion tts p2p"
225
225
ARG GRPC_BACKENDS
226
226
ARG MAKEFLAGS
227
+ ARG LD_FLAGS="-s -w"
227
228
228
229
ENV GRPC_BACKENDS=${GRPC_BACKENDS}
229
230
ENV GO_TAGS=${GO_TAGS}
230
231
ENV MAKEFLAGS=${MAKEFLAGS}
231
232
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
232
233
ENV NVIDIA_REQUIRE_CUDA="cuda>=${CUDA_MAJOR_VERSION}.0"
233
234
ENV NVIDIA_VISIBLE_DEVICES=all
235
+ ENV LD_FLAGS=${LD_FLAGS}
234
236
235
- WORKDIR /build
237
+ RUN echo "GO_TAGS: $GO_TAGS" && echo "TARGETARCH: $TARGETARCH"
236
238
237
- COPY . .
238
- COPY .git .
239
- RUN echo "GO_TAGS: $GO_TAGS"
239
+ WORKDIR /build
240
240
241
- RUN make prepare
242
241
243
242
# We need protoc installed, and the version in 22.04 is too old. We will create one as part installing the GRPC build below
244
243
# 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
256
255
fi
257
256
EOT
258
257
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
+
259
272
# stablediffusion does not tolerate a newer version of abseil, build it first
260
273
RUN GRPC_BACKENDS=backend-assets/grpc/stablediffusion make build
261
274
@@ -276,6 +289,33 @@ RUN if [ ! -d "/build/sources/go-piper/piper-phonemize/pi/lib/" ]; then \
276
289
# ##################################
277
290
# ##################################
278
291
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
+
279
319
# This is the final target. The result of this target will be the image uploaded to the registry.
280
320
# If you cannot find a more suitable place for an addition, this layer is a suitable place for it.
281
321
FROM requirements-drivers
0 commit comments