forked from helixml/helix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.runner
63 lines (44 loc) · 2.25 KB
/
Dockerfile.runner
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#syntax=docker/dockerfile:1.4
ARG TAG=2024-11-21a-empty
### BUILD
FROM golang:1.22 AS go-build-env
WORKDIR /workspace/helix
# <- COPY go.mod and go.sum files to the workspace
COPY go.mod .
COPY go.sum .
RUN go mod download
# COPY the source code as the last step
COPY . .
# Run tidy and show git diff for go.sum
# RUN go mod tidy && git diff --exit-code -- go.sum
# Build the Go app
# RUN go mod tidy && go mod download && CGO_ENABLED=0 go build -ldflags "-s -w" -o /helix
ARG APP_VERSION="v0.0.0+unknown"
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg/mod CGO_ENABLED=0 go build -ldflags "-s -w -X github.com/helixml/helix/api/pkg/data.Version=$APP_VERSION" -o /helix
### RUNNER CONTAINER
FROM registry.helix.ml/helix/runner-base:${TAG}
# Install ollama
RUN TEMP_DIR=$(mktemp -d /tmp/ollama_install_XXXXXX) && \
curl --retry 5 -L https://github.com/ollama/ollama/releases/download/v0.3.13/ollama-linux-amd64.tgz -o $TEMP_DIR/ollama.tgz && \
tar -xzf $TEMP_DIR/ollama.tgz -C $TEMP_DIR && \
mv $TEMP_DIR/bin/ollama /usr/bin/ollama && \
chmod +x /usr/bin/ollama && \
cp -r $TEMP_DIR/lib/ollama /usr/lib/ && \
rm -rf $TEMP_DIR
RUN mkdir -p /workspace/helix
WORKDIR /workspace/helix
# Copy runner directory from the repo
COPY runner ./runner
# Copy the cog wrapper, cog and cog-sdxl is installed in the base image, this is just the cog server
COPY cog/helix_cog_wrapper.py /workspace/cog-sdxl/helix_cog_wrapper.py
# So that the runner can function when run as non-root, symlink some stuff into
# locations in /tmp (needed for locked down OpenShift support)
RUN mkdir -p /tmp/helix/ollama /tmp/helix/src /tmp/helix/cache /tmp/helix/root-cache /tmp/helix/config /workspace/axolotl/dataset_cache && \
rm -rf /root/.cache && ln -s /tmp/helix/root-cache /root/.cache && \
rm -rf /.cache && ln -s /tmp/helix/cache /.cache && \
rm -rf /.config && ln -s /tmp/helix/config /.config && \
rm -rf /src && ln -s /tmp/helix/src /src && \
rm -rf /.ollama && ln -s /tmp/helix/ollama /.ollama && \
chmod -R 0777 /tmp/helix && chmod 0777 /root /workspace/cog-sdxl /workspace/axolotl /workspace/axolotl/dataset_cache
COPY --from=go-build-env /helix /workspace/helix/helix
ENTRYPOINT ["/workspace/helix/helix", "runner"]