Update Dockerfile
Browse files- Dockerfile +18 -19
Dockerfile
CHANGED
|
@@ -1,43 +1,41 @@
|
|
| 1 |
-
# Use the Bullseye-based image
|
| 2 |
FROM python:3.11-slim-bullseye
|
| 3 |
|
| 4 |
-
#
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Create necessary directories
|
| 8 |
RUN mkdir -p /app/downloads /app/extracted /app/state
|
| 9 |
|
| 10 |
-
# Copy requirements
|
| 11 |
COPY requirements.txt .
|
| 12 |
-
COPY system-requirements.txt . # Assuming you might use this file, otherwise it can be removed
|
| 13 |
|
| 14 |
-
# Install system dependencies
|
|
|
|
| 15 |
RUN apt-get update && \
|
| 16 |
-
apt-get install -y unrar && \
|
|
|
|
|
|
|
| 17 |
rm -rf /var/lib/apt/lists/*
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 21 |
-
|
| 22 |
-
# Copy the application code
|
| 23 |
COPY main.py .
|
| 24 |
COPY docker-entrypoint.sh .
|
| 25 |
|
| 26 |
-
# Make entrypoint executable
|
| 27 |
RUN chmod +x docker-entrypoint.sh
|
| 28 |
|
| 29 |
-
# Expose
|
| 30 |
VOLUME ["/app/extracted", "/app/state"]
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
#
|
| 34 |
-
RUN
|
|
|
|
| 35 |
|
| 36 |
-
# Create and switch to a non-root user
|
| 37 |
-
RUN useradd -m -u 1000 user
|
| 38 |
USER user
|
| 39 |
|
| 40 |
-
# Set environment variables
|
| 41 |
ENV PYTHONUNBUFFERED=1
|
| 42 |
ENV HF_TOKEN=""
|
| 43 |
ENV SOURCE_REPO="Fred808/BG1"
|
|
@@ -45,5 +43,6 @@ ENV DOWNLOAD_FOLDER=/app/downloads
|
|
| 45 |
ENV EXTRACT_FOLDER=/app/extracted
|
| 46 |
ENV STATE_FOLDER=/app/state
|
| 47 |
|
|
|
|
| 48 |
ENTRYPOINT ["./docker-entrypoint.sh"]
|
| 49 |
CMD ["python", "main.py"]
|
|
|
|
| 1 |
+
# Use the Bullseye-based image to have access to apt-get
|
| 2 |
FROM python:3.11-slim-bullseye
|
| 3 |
|
| 4 |
+
# Set the working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Create necessary directories for the application
|
| 8 |
RUN mkdir -p /app/downloads /app/extracted /app/state
|
| 9 |
|
| 10 |
+
# Copy the Python requirements file
|
| 11 |
COPY requirements.txt .
|
|
|
|
| 12 |
|
| 13 |
+
# Install system dependencies from apt
|
| 14 |
+
# and Python dependencies from pip in a single layer to save space
|
| 15 |
RUN apt-get update && \
|
| 16 |
+
apt-get install -y --no-install-recommends unrar && \
|
| 17 |
+
pip install --no-cache-dir -r requirements.txt && \
|
| 18 |
+
apt-get clean && \
|
| 19 |
rm -rf /var/lib/apt/lists/*
|
| 20 |
|
| 21 |
+
# Copy the rest of the application code
|
|
|
|
|
|
|
|
|
|
| 22 |
COPY main.py .
|
| 23 |
COPY docker-entrypoint.sh .
|
| 24 |
|
| 25 |
+
# Make the entrypoint script executable
|
| 26 |
RUN chmod +x docker-entrypoint.sh
|
| 27 |
|
| 28 |
+
# Expose volumes for persistent data
|
| 29 |
VOLUME ["/app/extracted", "/app/state"]
|
| 30 |
|
| 31 |
+
# Create a non-root user and switch to it
|
| 32 |
+
# Note: Permissions are set before switching user
|
| 33 |
+
RUN useradd -m -s /bin/bash -u 1000 user && \
|
| 34 |
+
chown -R user:user /app
|
| 35 |
|
|
|
|
|
|
|
| 36 |
USER user
|
| 37 |
|
| 38 |
+
# Set environment variables for the application
|
| 39 |
ENV PYTHONUNBUFFERED=1
|
| 40 |
ENV HF_TOKEN=""
|
| 41 |
ENV SOURCE_REPO="Fred808/BG1"
|
|
|
|
| 43 |
ENV EXTRACT_FOLDER=/app/extracted
|
| 44 |
ENV STATE_FOLDER=/app/state
|
| 45 |
|
| 46 |
+
# Set the entrypoint and default command
|
| 47 |
ENTRYPOINT ["./docker-entrypoint.sh"]
|
| 48 |
CMD ["python", "main.py"]
|