# Stage 1: Build stage FROM python:3.10-slim AS build-stage # Set the working directory in the container WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ gcc \ libpq-dev \ gdal-bin \ libgdal-dev \ python3-gdal \ && rm -rf /var/lib/apt/lists/* # Set environment variables for GDAL ENV GDAL_CONFIG=/usr/bin/gdal-config ENV CPLUS_INCLUDE_PATH=/usr/include/gdal ENV C_INCLUDE_PATH=/usr/include/gdal # Copy the requirements file into the container COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt # Stage 2: Final stage FROM python:3.10-slim AS final-stage # Set the working directory in the container WORKDIR /app # Install runtime dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ libpq5 \ gdal-bin \ && rm -rf /var/lib/apt/lists/* # Copy Python packages and dependencies from build stage COPY --from=build-stage /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages COPY --from=build-stage /usr/local/bin /usr/local/bin # Copy your application code COPY . . # Change permissions to allow all users to write to the /app directory RUN chmod 777 /app # Expose port 8501 for Streamlit EXPOSE 8501 # Define environment variable for Streamlit ENV STREAMLIT_PORT=8501 # Command to run the Streamlit app CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0"]