FROM python:3.10-slim # Create a new user - myuser RUN useradd -ms /bin/bash myuser # Switch to that user USER myuser # Create a .cache directory for Hugging Face transformers # This is necessary to avoid permission issues when running the container as a non-root user, # especially when using Hugging Face libraries. # The directory will be used to store cached files, models, etc. # The permissions are set to allow read/write access for the user. RUN mkdir -p /home/myuser/.cache && chmod -R 755 /home/myuser/.cache ADD requirements.txt . RUN pip install -r requirements.txt ADD my_server.py . EXPOSE 8000 CMD ["python", "my_server.py"]