mauifire / Dockerfile
NextDrought's picture
Run as nob-root user
9cdfb13 verified
raw
history blame contribute delete
No virus
1.08 kB
# Stage 1: Build stage
FROM python:3.10
# 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
# Create a non-root user
RUN useradd -m -s /bin/bash appuser
# 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
# Copy the rest of the application code
COPY . .
# Change ownership of the /app directory to appuser
RUN chown -R appuser:appuser /app
# Switch to the non-root user
USER appuser
# Expose port 8501 for Streamlit
EXPOSE 8501
# Command to run the Streamlit app
CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0"]