Update Dockerfile
Browse files- Dockerfile +23 -16
Dockerfile
CHANGED
|
@@ -1,27 +1,34 @@
|
|
|
|
|
| 1 |
FROM python:3.9.13
|
| 2 |
-
USER root
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
git \
|
| 8 |
-
&& \
|
| 9 |
-
rm -rf /var/lib/apt/lists/*
|
| 10 |
|
|
|
|
| 11 |
RUN useradd -m -u 1000 user
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
ENV HOME=/home/user \
|
| 15 |
-
PATH=/home/user/.local/bin:$PATH
|
| 16 |
|
|
|
|
| 17 |
WORKDIR $HOME/app
|
| 18 |
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
|
|
|
|
|
|
| 25 |
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
|
|
|
|
|
| 1 |
+
# Use the official Python image as a base
|
| 2 |
FROM python:3.9.13
|
|
|
|
| 3 |
|
| 4 |
+
# Set environment variables
|
| 5 |
+
ENV HOME=/home/user
|
| 6 |
+
ENV PATH=$HOME/.local/bin:$PATH
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
# Create a non-root user and set ownership for HOME directory
|
| 9 |
RUN useradd -m -u 1000 user
|
| 10 |
+
RUN chown -R user:user $HOME
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
# Set the working directory
|
| 13 |
WORKDIR $HOME/app
|
| 14 |
|
| 15 |
+
# Clone the shap-e repository from GitHub (optional based on your needs)
|
| 16 |
+
# RUN git clone https://github.com/openai/shap-e .
|
| 17 |
|
| 18 |
+
# Copy the local app files into the container
|
| 19 |
+
COPY --chown=user . .
|
| 20 |
+
|
| 21 |
+
# Create a requirements.txt file with specified dependencies
|
| 22 |
+
RUN echo "-e ." > requirements.txt \
|
| 23 |
+
&& echo "flask" >> requirements.txt \
|
| 24 |
+
&& echo "flask_cors" >> requirements.txt \
|
| 25 |
+
&& echo "gunicorn" >> requirements.txt
|
| 26 |
|
| 27 |
+
# Install Python dependencies
|
| 28 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 29 |
|
| 30 |
+
# Set Numba cache directory (optional)
|
| 31 |
+
ENV NUMBA_CACHE_DIR=/tmp/numba_cache
|
| 32 |
|
| 33 |
+
# Default command to run the application
|
| 34 |
+
CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]
|