mirror of
https://github.com/data-privacy-stack/presidio.git
synced 2026-09-21 13:38:05 -05:00
46 lines
1.9 KiB
Docker
46 lines
1.9 KiB
Docker
FROM python:3.12-windowsservercore@sha256:f2ab91b547b695c40a69cb1931cf382cb4019f56e1df5a83c86372d0cc8fb5a4
|
|
|
|
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 PORT=3000
|
|
WORKDIR /app
|
|
|
|
ENV ANALYZER_CONF_FILE=${ANALYZER_CONF_FILE}
|
|
ENV RECOGNIZER_REGISTRY_CONF_FILE=${RECOGNIZER_REGISTRY_CONF_FILE}
|
|
ENV NLP_CONF_FILE=${NLP_CONF_FILE}
|
|
|
|
RUN powershell -Command \
|
|
"Write-Host 'Downloading VC++ Redistributable...'; \
|
|
Invoke-WebRequest -Uri 'https://aka.ms/vs/16/release/vc_redist.x64.exe' -OutFile 'vc_redist.x64.exe' -UseBasicParsing; \
|
|
Write-Host 'Installing VC++ Redistributable...'; \
|
|
Start-Process -FilePath 'vc_redist.x64.exe' -ArgumentList '/quiet', '/install' -Wait; \
|
|
Write-Host 'VC++ Redistributable installed successfully'; \
|
|
Remove-Item 'vc_redist.x64.exe'"
|
|
|
|
COPY ${ANALYZER_CONF_FILE} /app/${ANALYZER_CONF_FILE}
|
|
COPY ${RECOGNIZER_REGISTRY_CONF_FILE} /app/${RECOGNIZER_REGISTRY_CONF_FILE}
|
|
COPY ${NLP_CONF_FILE} /app/${NLP_CONF_FILE}
|
|
|
|
COPY ./pyproject.toml /app/
|
|
RUN pip install poetry==2.3.2; poetry install --no-root --only=main -E server -E transformers
|
|
|
|
# install nlp models specified in NLP_CONF_FILE
|
|
COPY ./install_nlp_models.py .
|
|
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 \
|
|
CMD powershell -Command "try { Invoke-WebRequest -Uri http://localhost:$env:PORT/health -UseBasicParsing | Out-Null; exit 0 } catch { exit 1 }"
|
|
CMD ["powershell", "-Command", "poetry run waitress-serve --port=$env:PORT app:create_app"]
|