| FROM python:3.11-slim | |
| WORKDIR /app | |
| # 1. Install System Dependencies | |
| # default-jdk-headless ensures we get a compatible Java version (likely 17 or 21) | |
| RUN apt-get update && \ | |
| apt-get install -y default-jdk-headless build-essential git && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # 2. Copy files | |
| COPY . . | |
| # 3. Install Python libraries | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # 4. Create User (Fixed for 'dash' shell) | |
| # Changed '&>/dev/null' to '>/dev/null 2>&1' to match the system shell | |
| RUN id -u user >/dev/null 2>&1 || useradd -m -u 1000 user | |
| # 5. Fix Permissions | |
| RUN chown -R user:user /app && \ | |
| chown -R user:user /home/user | |
| # 6. Switch User | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # 7. Run | |
| EXPOSE 7860 | |
| CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"] |