Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ RUN python -m spacy download nl_core_news_sm

COPY . .

# Create a non-root user and set ownership
RUN useradd -m -u 1001 presidio && chown -R presidio:presidio /app

USER 1001

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ RUN pip install --no-cache-dir -r requirements.txt

COPY . .

# Create a non-root user and set ownership
RUN useradd -m -u 1001 presidio && chown -R presidio:presidio /app

USER 1001

CMD ["python", "serve.py"]
7 changes: 7 additions & 0 deletions presidio-analyzer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ARG NLP_CONF_FILE=presidio_analyzer/conf/default.yaml
ARG ANALYZER_CONF_FILE=presidio_analyzer/conf/default_analyzer.yaml
ARG RECOGNIZER_REGISTRY_CONF_FILE=presidio_analyzer/conf/default_recognizers.yaml
ENV PIP_NO_CACHE_DIR=1
ENV POETRY_VIRTUALENVS_CREATE=false

ENV ANALYZER_CONF_FILE=${ANALYZER_CONF_FILE}
ENV RECOGNIZER_REGISTRY_CONF_FILE=${RECOGNIZER_REGISTRY_CONF_FILE}
Expand Down Expand Up @@ -32,6 +33,12 @@ COPY ./install_nlp_models.py /app/
RUN poetry run python install_nlp_models.py --conf_file ${NLP_CONF_FILE}

COPY . /app/

# Create a non-root user and set ownership
RUN useradd -m -u 1001 presidio && chown -R presidio:presidio /app

USER 1001

EXPOSE ${PORT}
HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
CMD curl -f http://localhost:${PORT}/health || exit 1
Expand Down
5 changes: 5 additions & 0 deletions presidio-analyzer/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ RUN apt-get update \
&& apt-get install -y build-essential

RUN pip install poetry

# Create a non-root user for development
RUN useradd -m -u 1001 presidio

USER 1001
7 changes: 7 additions & 0 deletions presidio-analyzer/Dockerfile.stanza
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ARG NLP_CONF_FILE=presidio_analyzer/conf/default.yaml
ARG ANALYZER_CONF_FILE=presidio_analyzer/conf/default_analyzer.yaml
ARG RECOGNIZER_REGISTRY_CONF_FILE=presidio_analyzer/conf/default_recognizers.yaml
ENV PIP_NO_CACHE_DIR=1
ENV POETRY_VIRTUALENVS_CREATE=false

ENV ANALYZER_CONF_FILE=${ANALYZER_CONF_FILE}
ENV RECOGNIZER_REGISTRY_CONF_FILE=${RECOGNIZER_REGISTRY_CONF_FILE}
Expand Down Expand Up @@ -31,6 +32,12 @@ COPY ./install_nlp_models.py /app/
RUN poetry run python install_nlp_models.py --conf_file ${NLP_CONF_FILE}

COPY . /app/

# Create a non-root user and set ownership
RUN useradd -m -u 1001 presidio && chown -R presidio:presidio /app

USER 1001

EXPOSE ${PORT}
HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
CMD curl -f http://localhost:${PORT}/health || exit 1
Expand Down
7 changes: 7 additions & 0 deletions presidio-analyzer/Dockerfile.transformers
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ARG NLP_CONF_FILE=presidio_analyzer/conf/transformers.yaml
ARG ANALYZER_CONF_FILE=presidio_analyzer/conf/default_analyzer.yaml
ARG RECOGNIZER_REGISTRY_CONF_FILE=presidio_analyzer/conf/default_recognizers.yaml
ENV PIP_NO_CACHE_DIR=1
ENV POETRY_VIRTUALENVS_CREATE=false
WORKDIR /app

ENV ANALYZER_CONF_FILE=${ANALYZER_CONF_FILE}
Expand All @@ -28,6 +29,12 @@ COPY ./install_nlp_models.py /app/
RUN poetry run python install_nlp_models.py --conf_file ${NLP_CONF_FILE}

COPY . /app/

# Create a non-root user and set ownership
RUN useradd -m -u 1001 presidio && chown -R presidio:presidio /app

USER 1001

EXPOSE ${PORT}
HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
CMD curl -f http://localhost:${PORT}/health || exit 1
Expand Down
5 changes: 5 additions & 0 deletions presidio-analyzer/Dockerfile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ COPY ${NLP_CONF_FILE} ${NLP_CONF_FILE}
RUN poetry run python install_nlp_models.py --conf_file $Env:NLP_CONF_FILE

COPY . .

# Create a non-root user for Windows container
RUN net user presidio /add
USER presidio

EXPOSE ${PORT}

HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
Expand Down
6 changes: 6 additions & 0 deletions presidio-anonymizer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM python:3.13-slim

ENV PIP_NO_CACHE_DIR=1
ENV POETRY_VIRTUALENVS_CREATE=false

ENV PORT=3000
ENV WORKERS=1
Expand All @@ -15,6 +16,11 @@ RUN pip install poetry && poetry install --no-root --only=main -E server

COPY . /app/

# Create a non-root user and set ownership
RUN useradd -m -u 1001 presidio && chown -R presidio:presidio /app

USER 1001

EXPOSE ${PORT}
HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
CMD curl -f http://localhost:${PORT}/health || exit 1
Expand Down
5 changes: 5 additions & 0 deletions presidio-anonymizer/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ RUN apt-get update \
&& apt-get install -y build-essential

RUN pip install poetry

# Create a non-root user for development
RUN useradd -m -u 1001 presidio

USER 1001
4 changes: 4 additions & 0 deletions presidio-anonymizer/Dockerfile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ RUN python.exe -m pip install --upgrade pip; pip install poetry; poetry install

COPY . /app/

# Create a non-root user for Windows container
RUN net user presidio /add
USER presidio

EXPOSE ${PORT}
HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
CMD powershell -Command "try { Invoke-WebRequest -Uri http://localhost:$env:PORT/health -UseBasicParsing | Out-Null; exit 0 } catch { exit 1 }"
Expand Down
10 changes: 10 additions & 0 deletions presidio-image-redactor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ARG NLP_CONF_FILE
ARG ANALYZER_CONF_FILE
ARG RECOGNIZER_REGISTRY_CONF_FILE
ENV PIP_NO_CACHE_DIR=1
ENV POETRY_VIRTUALENVS_CREATE=false

ENV ANALYZER_CONF_FILE=${ANALYZER_CONF_FILE}
ENV RECOGNIZER_REGISTRY_CONF_FILE=${RECOGNIZER_REGISTRY_CONF_FILE}
Expand All @@ -26,7 +27,16 @@ RUN apt-get update \
COPY ./pyproject.toml /app/
RUN pip install poetry && poetry install --no-root --only=main -E server

# Install spaCy model during build (as root) so it's available to non-root user at runtime
RUN python -m spacy download en_core_web_lg

COPY . /app/

# Create a non-root user and set ownership
RUN useradd -m -u 1001 presidio && chown -R presidio:presidio /app

USER 1001

EXPOSE ${PORT}
HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
CMD curl -f http://localhost:${PORT}/health || exit 1
Expand Down
5 changes: 5 additions & 0 deletions presidio-image-redactor/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ RUN apt-get update \
&& apt-get install ffmpeg libsm6 libxext6 -y

RUN pip install poetry

# Create a non-root user for development
RUN useradd -m -u 1001 presidio

USER 1001