tt3d / Dockerfile
Spanicin's picture
Update Dockerfile
2b70b27 verified
# Use the official Python image as a base
FROM python:3.9.13
# Set environment variables
ENV HOME=/home/user
ENV PATH=$HOME/.local/bin:$PATH
# Create a non-root user and set ownership for HOME directory
RUN useradd -m -u 1000 user
RUN chown -R user:user $HOME
# Set the working directory
WORKDIR $HOME/app
# Clone the shap-e repository from GitHub (optional based on your needs)
RUN git clone https://github.com/openai/shap-e .
# Copy the local app files into the container
COPY --chown=user . .
# Create a requirements.txt file with specified dependencies
RUN echo "-e ." > requirements.txt \
&& echo "flask" >> requirements.txt \
&& echo "flask_cors" >> requirements.txt \
&& echo "PyYAML" >> requirements.txt \
&& echo "ipywidgets" >> requirements.txt \
&& echo "gunicorn" >> requirements.txt
# Create a directory for model cache with appropriate permissions
RUN mkdir -p $HOME/app/shap_e_model_cache
RUN chown -R user:user $HOME/app/shap_e_model_cache
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Set Numba cache directory (optional)
ENV NUMBA_CACHE_DIR=/tmp/numba_cache
# Default command to run the application
CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]