Skip to content

Commit 4a86a53

Browse files
committed
Added OCR service user to docker img.
1 parent cecdf9b commit 4a86a53

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,15 @@ RUN python3.12 -m venv "$VIRTUAL_ENV" && "$VIRTUAL_ENV/bin/python" && "$VIRTUAL_
138138
# Byte-compile using venv python
139139
RUN "$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
142152
CMD ["/bin/bash", "start_service_production.sh"]

0 commit comments

Comments
 (0)