smgpulse007/dfexample icon
public
Published on 5/1/2025
dockerfileExample

This is an example dockerfile from a similar dockerized application running on production.

Prompts
Working DockerFile for streamlit production apps
A sample prompt
This is an example dockerfile from a similar dockerized application running on production.
# Use the official lightweight Python 3.11 image
FROM python:3.11-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    ACCEPT_EULA=Y \
    SQL_SERVER=default_server \
    SQL_DATABASE=default_database \
    SQL_USERNAME=default_user \
    SQL_PASSWORD=default_password \
    MLFLOW_TRACKING_URI=http://mlflow:5000

# Install system dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    build-essential unixodbc-dev curl gnupg2 && \
    curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
    curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
    apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql17 && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

# Copy and install requirements first
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt && \
    pip install --no-cache-dir streamlit==1.28.0 && \
    pip list | grep streamlit

# Create necessary directories
RUN mkdir -p /app/data

# Copy the rest of the application files
COPY . .

# List files to debug
RUN echo "Files in container:" && ls -la /app

# Expose Streamlit port
EXPOSE 8501

# Run the Streamlit app
CMD ["python", "-m", "streamlit", "run", "dashboard.py", "--server.port=8501", "--server.address=0.0.0.0"]