File size: 1,801 Bytes
d78a48e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6864fef
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
# syntax=docker/dockerfile:1
ARG DEBIAN_VERSION=bullseye

################################################################################
# Use debian image as downloader image for final stage.
# https://hub.docker.com/_/debian
################################################################################
FROM debian:${DEBIAN_VERSION}-slim AS downloader

# Set working directory.
WORKDIR /download

# Install curl.
RUN apt-get update && apt-get install -y curl

# Download latest llamafile from github.
RUN curl -L -o ./llamafile https://github.com/Mozilla-Ocho/llamafile/releases/download/0.8.9/llamafile-0.8.9

# Make llamafile executable.
RUN chmod +x ./llamafile

# Download the Code-Llama-3-8B-Q8_0 model
RUN curl -L -o ./Code-Llama-3-8B-Q8_0.gguf https://huggingface.co/bartowski/Code-Llama-3-8B-GGUF/resolve/main/Code-Llama-3-8B-Q8_0.gguf

################################################################################
# Use debian image as final image.
# https://hub.docker.com/_/debian
################################################################################
FROM debian:${DEBIAN_VERSION}-slim AS final

# Create user to run llamafile as non-root.
RUN addgroup --gid 1000 user
RUN adduser --uid 1000 --gid 1000 --disabled-password --gecos "" user

# Switch to user.
USER user

# Set working directory.
WORKDIR /usr/src/app

# Copy llamafile and model from downloader image.
COPY --from=downloader /download/llamafile ./llamafile
COPY --from=downloader /download/Code-Llama-3-8B-Q8_0.gguf ./Code-Llama-3-8B-Q8_0.gguf

# Expose 8080 port.
EXPOSE 7860

# Set entrypoint.
ENTRYPOINT ["/bin/sh", "/usr/src/app/llamafile"]

# Set default command to run the server with the downloaded model.
CMD ["--server", "--host", "0.0.0.0", "--port", "7860", "-m", "./Code-Llama-3-8B-Q8_0.gguf"]