-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (42 loc) · 1.51 KB
/
Copy pathDockerfile
File metadata and controls
55 lines (42 loc) · 1.51 KB
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
# This is an example Dockerfile that builds a minimal container for running LK Agents
# syntax=docker/dockerfile:1
ARG PYTHON_VERSION=3.12.2
FROM python:${PYTHON_VERSION}-slim
# Keeps Python from buffering stdout and stderr to avoid situations where
# the application crashes without emitting any logs due to buffering.
ENV PYTHONUNBUFFERED=1
# Create a non-privileged user that the app will run under.
# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/home/appuser" \
--shell "/sbin/nologin" \
--uid "${UID}" \
appuser
# Install gcc and other build dependencies.
RUN apt-get update && \
apt-get install -y \
gcc \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
USER appuser
RUN mkdir -p /home/appuser/.cache
RUN chown -R appuser /home/appuser/.cache
# Add local bin to PATH for the appuser
ENV PATH="/home/appuser/.local/bin:$PATH"
# Set Hugging Face cache environment variables
ENV HF_HOME="/home/appuser/.cache/huggingface"
ENV HUGGINGFACE_HUB_CACHE="/home/appuser/.cache/huggingface/hub"
ENV HF_HUB_OFFLINE=0
WORKDIR /home/appuser
COPY --chown=appuser:appuser . .
RUN find . -name "*.egg-info" -type d -exec rm -rf {} + 2>/dev/null || true
RUN python -m pip install --user --no-cache-dir .
# ensure that any dependent models are downloaded at build-time
RUN python main.py download-files
# expose healthcheck port
EXPOSE 8081
# Run the application.
CMD ["python", "main.py", "start"]