File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -138,5 +138,15 @@ RUN python3.12 -m venv "$VIRTUAL_ENV" && "$VIRTUAL_ENV/bin/python" && "$VIRTUAL_
138138# Byte-compile using venv python
139139RUN "$VIRTUAL_ENV/bin/python" -m compileall /ocr_service
140140
141+ # Run as non-root by default for Kubernetes restricted policies.
142+ ARG OCR_SERVICE_UID=10001
143+ ARG OCR_SERVICE_GID=10001
144+ RUN groupadd --system --gid "$OCR_SERVICE_GID" ocrsvc && \
145+ useradd --system --uid "$OCR_SERVICE_UID" --gid "$OCR_SERVICE_GID" --create-home --home-dir /home/ocrsvc --shell /usr/sbin/nologin ocrsvc && \
146+ mkdir -p /ocr_service/tmp /ocr_service/log && \
147+ chown -R ocrsvc:ocrsvc /ocr_service/tmp /ocr_service/log /home/ocrsvc
148+ ENV HOME=/home/ocrsvc
149+ USER ocrsvc
150+
141151# Now run the simple api
142152CMD ["/bin/bash" , "start_service_production.sh" ]
You can’t perform that action at this time.
0 commit comments