Skip to content

Commit

Permalink
Run llmstudio docker image as llmstudio user instead of root user
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkraljevic authored Jun 26, 2023
1 parent e897bea commit af1a8ab
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
.github
data
output
27 changes: 25 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,33 @@ RUN apt-get update && apt-get install -y \
&& apt install -y python3.10 \
&& apt install -y python3.10-distutils \
&& rm -rf /var/lib/apt/lists/*

# Pick an unusual UID for the llmstudio user.
# In particular, don't pick 1000, which is the default ubuntu user number.
# Force ourselves to test with UID mismatches in the common case.
RUN adduser --uid 1999 llmstudio
USER llmstudio

# Python virtualenv is installed in /home/llmstudio/.local
# Application code and data lives in /workspace
#
# Make all of the files in the llmstudio directory writable so that the
# application can install other (non-persisted) new packages and other things
# if it wants to. This is really not advisable, though, since it's lost when
# the container exits.
WORKDIR /workspace
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
RUN \
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 && \
chmod -R a+w /home/llmstudio
COPY Makefile .
COPY Pipfile .
COPY Pipfile.lock .
RUN \
make setup && \
chmod -R a+w /home/llmstudio
COPY . .
RUN make setup

ENV HOME=/home/llmstudio
ENV H2O_WAVE_MAX_REQUEST_SIZE=25MB
ENV H2O_WAVE_NO_LOG=True
ENV H2O_WAVE_PRIVATE_DIR="/download/@/workspace/output/download"
Expand Down
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,29 @@ wave-no-reload:
H2O_WAVE_PRIVATE_DIR="/download/@$(PWD)/output/download" \
$(PIPENV) run wave run --no-reload app

.PHONY: docker-build-nightly
docker-build-nightly:
docker build -t gcr.io/vorvan/h2oai/h2o-llmstudio:nightly .

.PHONY: docker-run-nightly
docker-run-nightly:
ifeq (,$(wildcard ./data))
mkdir data
endif
ifeq (,$(wildcard ./output))
mkdir output
endif
docker run \
--runtime=nvidia \
--shm-size=64g \
--init \
--rm \
-u `id -u`:`id -g` \
-p 10101:10101 \
-v `pwd`/data:/workspace/data \
-v `pwd`/output:/workspace/output \
gcr.io/vorvan/h2oai/h2o-llmstudio:nightly

.PHONY: shell
shell:
$(PIPENV) shell
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ docker run \
--shm-size=64g \
--init \
--rm \
-u `id -u`:`id -g` \
-p 10101:10101 \
-v `pwd`/data:/workspace/data \
-v `pwd`/output:/workspace/output \
Expand All @@ -162,6 +163,7 @@ docker run \
--shm-size=64g \
--init \
--rm \
-u `id -u`:`id -g` \
-p 10101:10101 \
-v `pwd`/data:/workspace/data \
-v `pwd`/output:/workspace/output \
Expand Down

0 comments on commit af1a8ab

Please sign in to comment.