commit 70cb172f11e6ac4c3c9700573a3e8be7f23cf45b
parent 073cf473d36ae292947c521556a9e36bcd48c154
Author: Stefan Koch <programming@stefan-koch.name>
Date: Sun, 6 Aug 2023 11:17:51 +0200
run as a custom user inside container
Diffstat:
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/Dockerfile b/Dockerfile
@@ -12,12 +12,14 @@ COPY pyproject.toml /opt/nlparrot/
COPY src/nlparrot /opt/nlparrot/src/nlparrot
RUN pip install -e /opt/nlparrot
-RUN python -c 'import stanza; [stanza.download(model) for model in ["multilingual", "hr"]]' \
- && python -m spacy download hr_core_news_sm
+# installs a Python package, thus before creation of user
+RUN python -m spacy download hr_core_news_sm
-# TODO: Does not play well together with model download out-of-the-box
-# RUN useradd --create-home nlparrot
-# WORKDIR /home/nlparrot
-# USER nlparrot
+RUN useradd --create-home nlparrot
+WORKDIR /home/nlparrot
+USER nlparrot
+
+# after creation of user, so that it downloads into the user home directory
+RUN python -c 'import stanza; [stanza.download(model) for model in ["multilingual", "hr"]]'
CMD ["python", "/opt/nlparrot/src/nlparrot/server.py"]