Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +21 -12
Dockerfile
CHANGED
|
@@ -1,18 +1,27 @@
|
|
| 1 |
-
# 1. Start with a
|
| 2 |
-
FROM python:3.10-slim
|
| 3 |
|
| 4 |
-
# 2. Set
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
-
# 3. Install git
|
| 8 |
-
RUN apt-get update && apt-get install -y git
|
|
|
|
| 9 |
|
| 10 |
-
# 4.
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
-
# 5. Copy
|
| 15 |
-
COPY ./
|
|
|
|
| 16 |
|
| 17 |
-
# 6.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
CMD ["python", "mine_diffs.py"]
|
|
|
|
| 1 |
+
# 1. Start with a stable base image
|
| 2 |
+
FROM python:3.10.13-slim-bullseye
|
| 3 |
|
| 4 |
+
# 2. Set environment variables
|
| 5 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
+
ENV PYTHONUNBUFFERED=1
|
| 7 |
|
| 8 |
+
# 3. Install git as the root user
|
| 9 |
+
RUN apt-get update && apt-get install -y --no-install-recommends git && \
|
| 10 |
+
apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
+
# 4. Create a non-root user and the application directory
|
| 13 |
+
RUN useradd -m -u 1000 user
|
| 14 |
+
WORKDIR /home/user/app
|
| 15 |
|
| 16 |
+
# 5. Copy files and set ownership for the non-root user
|
| 17 |
+
COPY --chown=user:user ./requirements.txt ./requirements.txt
|
| 18 |
+
COPY --chown=user:user ./mine_diffs.py ./mine_diffs.py
|
| 19 |
|
| 20 |
+
# 6. Switch to the non-root user
|
| 21 |
+
USER user
|
| 22 |
+
|
| 23 |
+
# 7. Install Python dependencies as the non-root user
|
| 24 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 25 |
+
|
| 26 |
+
# 8. Set the command to automatically run the script
|
| 27 |
CMD ["python", "mine_diffs.py"]
|