Commit ·
10702ec
1
Parent(s): baadc3e
Updated
Browse files- Dockerfile +25 -20
- Dockerfile_backup +29 -0
Dockerfile
CHANGED
|
@@ -1,29 +1,34 @@
|
|
| 1 |
-
FROM python:3.9
|
| 2 |
|
| 3 |
-
# Install
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
libglib2.0-0 \
|
| 8 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
|
| 22 |
|
| 23 |
-
# Set environment variables
|
|
|
|
|
|
|
| 24 |
ENV FLASK_APP=app.py
|
| 25 |
-
ENV FLASK_RUN_HOST=0.0.0.0
|
| 26 |
|
| 27 |
-
#
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
|
|
|
| 1 |
+
FROM python:3.9
|
| 2 |
|
| 3 |
+
# Install dependencies and set up the environment for dependency installation
|
| 4 |
+
WORKDIR /code
|
| 5 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 6 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
# Create a non-root user (with UID 1000) to avoid permission issues
|
| 9 |
+
RUN useradd -m -u 1000 user
|
| 10 |
|
| 11 |
+
USER user
|
| 12 |
+
ENV HOME=/home/user \
|
| 13 |
+
PATH=/home/user/.local/bin:$PATH
|
| 14 |
|
| 15 |
+
# Set up the working directory for the application
|
| 16 |
+
WORKDIR $HOME/app
|
| 17 |
|
| 18 |
+
# Create writable directories for InsightFace models and Matplotlib config
|
| 19 |
+
RUN mkdir -p $HOME/app/insightface_models $HOME/app/.config/matplotlib
|
| 20 |
|
| 21 |
+
# Set environment variables so that InsightFace and Matplotlib use the writable directories
|
| 22 |
+
ENV INSIGHTFACE_HOME=$HOME/app/insightface_models
|
| 23 |
+
ENV MPLCONFIGDIR=$HOME/app/.config/matplotlib
|
| 24 |
ENV FLASK_APP=app.py
|
|
|
|
| 25 |
|
| 26 |
+
# Copy the application code (ensuring proper ownership)
|
| 27 |
+
COPY --chown=user . $HOME/app
|
| 28 |
+
|
| 29 |
+
# Expose the port your Flask app will run on
|
| 30 |
+
EXPOSE 7890
|
| 31 |
+
|
| 32 |
+
# Command to run the Flask application
|
| 33 |
+
CMD ["flask", "run", "--host=0.0.0.0", "--port", "7890"]
|
| 34 |
|
Dockerfile_backup
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.9-slim
|
| 2 |
+
|
| 3 |
+
# Install system dependencies for building PyQt5 and OpenCV
|
| 4 |
+
RUN apt-get update && apt-get install -y \
|
| 5 |
+
build-essential \
|
| 6 |
+
libgl1-mesa-glx \
|
| 7 |
+
libglib2.0-0 \
|
| 8 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
# Set the working directory
|
| 11 |
+
WORKDIR /app
|
| 12 |
+
|
| 13 |
+
# Copy requirements and install Python dependencies
|
| 14 |
+
COPY requirements.txt ./
|
| 15 |
+
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
|
| 16 |
+
|
| 17 |
+
# Copy the rest of the application code
|
| 18 |
+
COPY . .
|
| 19 |
+
|
| 20 |
+
# Expose the port (adjust if needed)
|
| 21 |
+
EXPOSE 7890
|
| 22 |
+
|
| 23 |
+
# Set environment variables for a Flask app
|
| 24 |
+
ENV FLASK_APP=app.py
|
| 25 |
+
ENV FLASK_RUN_HOST=0.0.0.0
|
| 26 |
+
|
| 27 |
+
# Command to run the application
|
| 28 |
+
CMD ["flask", "run", "--port=7890"]
|
| 29 |
+
|