typhoon-data-analysis / Dockerfile
euler314's picture
Update Dockerfile
e7651f1 verified
raw
history blame
1.18 kB
FROM python:3.10-slim
WORKDIR /code
# Install system dependencies required for cartopy and other packages
RUN apt-get update && apt-get install -y \
gcc \
g++ \
libproj-dev \
proj-data \
proj-bin \
libgeos-dev \
libgeos-c1v5 \
git \
&& rm -rf /var/lib/apt/lists/*
# Create data directory and set permissions
RUN mkdir -p /code/data && \
chmod 777 /code/data
# Create matplotlib config directory and set permissions
RUN mkdir -p /tmp/matplotlib && \
chmod 777 /tmp/matplotlib
# Set matplotlib config directory
ENV MPLCONFIGDIR=/tmp/matplotlib
# Copy requirements file
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Set environment variables
ENV DATA_PATH=/code/data
# Expose port
EXPOSE 7860
# Create non-root user
RUN useradd -m -u 1000 appuser && \
chown -R appuser:appuser /code
# Switch to non-root user
USER appuser
# Create entrypoint script
RUN echo '#!/bin/bash\n\
python app.py --data_path=/code/data' > /code/entrypoint.sh && \
chmod +x /code/entrypoint.sh
# Set the entrypoint
ENTRYPOINT ["/code/entrypoint.sh"]