Commit ·
a1bbf36
1
Parent(s): a371525
Modifying Dockerfile
Browse files- Dockerfile +27 -24
Dockerfile
CHANGED
|
@@ -1,34 +1,37 @@
|
|
| 1 |
-
#
|
| 2 |
-
#
|
| 3 |
-
# Base image
|
| 4 |
FROM python:3.9
|
| 5 |
|
| 6 |
-
# --------------------------------------------------------------
|
| 7 |
-
# 1.
|
| 8 |
RUN useradd -m -u 1000 user
|
| 9 |
-
USER user
|
| 10 |
|
| 11 |
-
#
|
|
|
|
| 12 |
ENV HOME=/home/user \
|
| 13 |
-
PATH="$HOME/.local/bin:$PATH" \
|
| 14 |
PYTHONUNBUFFERED=1 \
|
| 15 |
-
PIP_NO_CACHE_DIR=1
|
| 16 |
-
|
| 17 |
-
# --------------------------------------------------------------
|
| 18 |
-
# 2. project files and Python deps
|
| 19 |
-
WORKDIR $HOME/app
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
COPY --chown=user . .
|
| 27 |
|
| 28 |
-
# --------------------------------------------------------------
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
| 1 |
+
# ---------------------------------------------------------------------
|
| 2 |
+
# Base image – use the full tag so `wget` is available for the steps
|
|
|
|
| 3 |
FROM python:3.9
|
| 4 |
|
| 5 |
+
# ---------------------------------------------------------------------
|
| 6 |
+
# 1. Create UID-1000 account *and its home directory*.
|
| 7 |
RUN useradd -m -u 1000 user
|
|
|
|
| 8 |
|
| 9 |
+
# Environment: declare the home dir now (some HF-injected commands
|
| 10 |
+
# look at $HOME) but stay root for the next layers.
|
| 11 |
ENV HOME=/home/user \
|
|
|
|
| 12 |
PYTHONUNBUFFERED=1 \
|
| 13 |
+
PIP_NO_CACHE_DIR=1 \
|
| 14 |
+
PATH="$HOME/.local/bin:$PATH"
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
# ---------------------------------------------------------------------
|
| 17 |
+
# 2. Install Python dependencies **as root** so the console scripts
|
| 18 |
+
# land in /usr/local/bin (already on PATH at runtime).
|
| 19 |
+
WORKDIR /app # temporary build context
|
| 20 |
+
COPY requirements.txt /tmp/reqs.txt
|
| 21 |
+
RUN pip install --no-cache-dir -r /tmp/reqs.txt \
|
| 22 |
+
&& rm /tmp/reqs.txt
|
| 23 |
|
| 24 |
+
# ---------------------------------------------------------------------
|
| 25 |
+
# 3. Switch to the non-root user for the final image,
|
| 26 |
+
# then copy the source tree.
|
| 27 |
+
USER user
|
| 28 |
+
WORKDIR $HOME/app
|
| 29 |
COPY --chown=user . .
|
| 30 |
|
| 31 |
+
# ---------------------------------------------------------------------
|
| 32 |
+
# 4. Launch: $PORT is set by the platform at runtime; fall back to 7860
|
| 33 |
+
# for local docker runs.
|
| 34 |
+
CMD streamlit run app.py \
|
| 35 |
+
--server.port=${PORT:-7860} \
|
| 36 |
+
--server.headless true \
|
| 37 |
+
--server.address 0.0.0.0
|