| FROM python:3.10 | |
| # Install system-level dependencies | |
| COPY packages.txt . | |
| RUN apt-get update && \ | |
| xargs -a packages.txt apt-get install -y && \ | |
| apt-get clean && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Set up a new user named "user" with user ID 1000 | |
| RUN useradd -m -u 1000 user | |
| # Set working directory | |
| WORKDIR /home/user/app | |
| # Copy requirements first for better caching | |
| COPY requirements.txt . | |
| RUN pip3 install -r requirements.txt | |
| # Copy the rest of the application | |
| COPY --chown=user:user . . | |
| # Set permissions (but don't fail if directories already exist) | |
| RUN chmod -R 777 . && \ | |
| chown -R user:user . | |
| # Switch to the "user" user | |
| USER user | |
| # Set environment variables | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| CMD ["python", "main.py"] |