mirror of
https://github.com/data-privacy-stack/presidio.git
synced 2026-07-23 11:20:55 -05:00
Dockerize Anonymizer + Add Compose
This commit is contained in:
14
Dockerfile
Normal file
14
Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
||||
FROM python:3.7
|
||||
|
||||
ARG NAME
|
||||
ARG PORT
|
||||
WORKDIR /usr/bin/${NAME}
|
||||
|
||||
RUN pip install pipenv
|
||||
|
||||
COPY ./${NAME} /usr/bin/${NAME}
|
||||
|
||||
RUN pipenv lock --requirements > requirements.txt
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
CMD flask run
|
||||
@@ -1,32 +0,0 @@
|
||||
FROM python:3.7-slim
|
||||
|
||||
ARG re2_version="2018-12-01"
|
||||
ARG NAME=presidio-analyzer
|
||||
|
||||
ENV PIP_NO_CACHE_DIR true
|
||||
|
||||
COPY ./${NAME}/Pipfile /usr/bin/${NAME}/Pipfile
|
||||
COPY ./${NAME}/Pipfile.lock /usr/bin/${NAME}/Pipfile.lock
|
||||
|
||||
WORKDIR /usr/bin/${NAME}
|
||||
|
||||
RUN apt-get update -qq \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
|
||||
wget build-essential && \
|
||||
wget -O re2.tar.gz https://github.com/google/re2/archive/${re2_version}.tar.gz && \
|
||||
mkdir re2 && tar --extract --file "re2.tar.gz" --directory "re2" --strip-components 1 && \
|
||||
cd re2 && make install && cd .. && rm -rf re2 && rm re2.tar.gz && \
|
||||
apt-get clean autoclean && apt-get autoremove --yes && rm -rf /var/lib/{apt,dpkg,cache,log}/
|
||||
|
||||
# Making sure we have pipenv
|
||||
RUN pip install pipenv
|
||||
# Updating setuptools
|
||||
RUN pip install --upgrade setuptools
|
||||
# Installing specified packages from Pipfile.lock
|
||||
RUN bash -c 'PIPENV_VENV_IN_PROJECT=1 pipenv sync'
|
||||
# Install for tests, consider making this optional
|
||||
RUN pipenv run python -m spacy download en_core_web_lg
|
||||
|
||||
# Print to screen the installed packages for easy debugging
|
||||
RUN pipenv run pip freeze
|
||||
|
||||
13
docker-compose.yml
Normal file
13
docker-compose.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
version: '3'
|
||||
services:
|
||||
presidio-anonymizer:
|
||||
build:
|
||||
context: ""
|
||||
args:
|
||||
- NAME=presidio-anonymizer
|
||||
environment:
|
||||
- FLASK_RUN_PORT=5001
|
||||
container_name: presidio-anonymizer
|
||||
image: presidio-anonymizer
|
||||
ports:
|
||||
- "5001:5001"
|
||||
@@ -1,8 +1,7 @@
|
||||
import api
|
||||
from app import app
|
||||
|
||||
|
||||
def test_anonymize():
|
||||
|
||||
tester = api.app.test_client()
|
||||
tester = app.test_client()
|
||||
resp = tester.post("/anonymize", json={"hello": 1, "world": "what?"})
|
||||
assert resp.json == {"hello": 1, "world": "what?"}
|
||||
|
||||
Reference in New Issue
Block a user