| FROM python:3.10.14-bookworm | |
| ARG USER_UID=10002 | |
| ARG USER_GID=$USER_UID | |
| ARG USERNAME=modelapi | |
| RUN groupadd --gid $USER_GID $USERNAME \ | |
| && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME | |
| # Copy required files | |
| RUN mkdir -p /modelapi && mkdir -p /home/$USERNAME/.modelapi | |
| COPY app /modelapi/app | |
| COPY sgmse /modelapi/sgmse | |
| COPY pyproject.toml /modelapi/pyproject.toml | |
| ENV CUDA_HOME=/usr/local/cuda-12.6 | |
| # Setup permissions | |
| RUN chown -R $USER_UID:$USER_GID /modelapi \ | |
| && chown -R $USER_UID:$USER_GID /home/$USERNAME/.modelapi \ | |
| && chown -R $USER_UID:$USER_GID /home/$USERNAME \ | |
| && chmod -R 755 /home/$USERNAME \ | |
| && chmod -R 755 /modelapi \ | |
| && chmod -R 755 /home/$USERNAME/.modelapi | |
| # Change to the user and do subnet installation | |
| USER $USERNAME | |
| RUN /bin/bash -c "python3 -m venv /modelapi/.venv && source /modelapi/.venv/bin/activate && pip3 install -e /modelapi/." | |
| EXPOSE 6500 | |
| CMD ["/bin/bash", "-c", "source /modelapi/.venv/bin/activate && python3 /modelapi/app/run.py"] |