-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example docker file for building agents (#401)
* Add example docker file for building agents * fix ruff errors * use entrypoint * one more type * fix typecheck workflow * more types
- Loading branch information
Showing
4 changed files
with
100 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# This is an example Dockerfile that builds a minimal container for running LK Agents | ||
# syntax=docker/dockerfile:1 | ||
ARG PYTHON_VERSION=3.11.6 | ||
FROM python:${PYTHON_VERSION}-slim | ||
|
||
# Prevents Python from writing pyc files. | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
|
||
# 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 | ||
|
||
WORKDIR /home/appuser | ||
|
||
COPY requirements.txt . | ||
RUN python -m pip install --user --no-cache-dir -r requirements.txt | ||
|
||
COPY . . | ||
|
||
# ensure that any dependent models are downloaded at build-time | ||
RUN python myagent.py download-files | ||
|
||
# Run the application. | ||
ENTRYPOINT ["python", "myagent.py"] | ||
CMD ["start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters