Spaces:
Sleeping
Sleeping
Refactor Dockerfile to enhance user creation and cache directory handling
Browse files- Dockerfile +11 -3
Dockerfile
CHANGED
@@ -15,7 +15,15 @@ FROM python:${PYTHON_VERSION}-slim as base
|
|
15 |
# the application crashes without emitting any logs due to buffering.
|
16 |
ENV PYTHONUNBUFFERED=1
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
USER appuser
|
21 |
|
@@ -27,8 +35,8 @@ ENV TRANSFORMERS_CACHE=$HOME/app/.cache/huggingface/hub
|
|
27 |
WORKDIR $HOME/app
|
28 |
|
29 |
COPY --chown=appuser ./requirements.txt requirements.txt
|
30 |
-
RUN mkdir -p /app/.cache \
|
31 |
-
&& chown -R appuser:appuser /app/.cache
|
32 |
|
33 |
# Download dependencies as a separate step to take advantage of Docker's caching.
|
34 |
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
|
|
|
15 |
# the application crashes without emitting any logs due to buffering.
|
16 |
ENV PYTHONUNBUFFERED=1
|
17 |
|
18 |
+
ARG UID=10001
|
19 |
+
RUN adduser \
|
20 |
+
--disabled-password \
|
21 |
+
--gecos "" \
|
22 |
+
--home "/nonexistent" \
|
23 |
+
--shell "/sbin/nologin" \
|
24 |
+
--no-create-home \
|
25 |
+
--uid "${UID}" \
|
26 |
+
appuser
|
27 |
|
28 |
USER appuser
|
29 |
|
|
|
35 |
WORKDIR $HOME/app
|
36 |
|
37 |
COPY --chown=appuser ./requirements.txt requirements.txt
|
38 |
+
RUN mkdir -p $HOME/app/.cache \
|
39 |
+
&& chown -R appuser:appuser $HOME/app/.cache
|
40 |
|
41 |
# Download dependencies as a separate step to take advantage of Docker's caching.
|
42 |
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
|