Skip to content

Commit 004d563

Browse files
authored
Merge pull request #14 from markusressel/feature/#4_docker
Feature/#4 docker
2 parents 808392d + 801ea4f commit 004d563

File tree

8 files changed

+76
-6
lines changed

8 files changed

+76
-6
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ python:
1616
# - "nightly" # currently points to 3.7-dev
1717
# command to install dependencies
1818
install:
19-
- pip install .
19+
- pip install --upgrade pip
20+
- pip install --no-cache-dir .
2021
#- pip install -r requirements.txt
2122
# command to run tests
2223
before_script:

Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.6-slim-buster
2+
3+
RUN apt-get update \
4+
&& apt-get -y install python-skimage git
5+
6+
WORKDIR /app
7+
8+
RUN pip install --no-cache-dir numpy
9+
COPY requirements.txt ./
10+
RUN pip install --no-cache-dir -r requirements.txt
11+
COPY . .
12+
13+
RUN pip install --no-cache-dir .
14+
15+
CMD [ "py-image-dedup", "daemon" ]

docker-compose.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
version: '3.7'
2+
3+
services:
4+
elasticsearch:
5+
image: docker.elastic.co/elasticsearch/elasticsearch:7.3.2
6+
ports:
7+
- "9200:9200"
8+
- "9300:9300"
9+
environment:
10+
- discovery.type=single-node
11+
networks:
12+
- docker-elk
13+
restart: on-failure
14+
py-image-dedup:
15+
build: .
16+
environment:
17+
# change configuration to your liking
18+
- PY_IMAGE_DEDUP_DRY_RUN=False
19+
- PY_IMAGE_DEDUP_ANALYSIS_SOURCE_DIRECTORIES=/mnt/source/
20+
- PY_IMAGE_DEDUP_ANALYSIS_RECURSIVE=True
21+
- PY_IMAGE_DEDUP_ANALYSIS_ACROSS_DIRS=True
22+
- PY_IMAGE_DEDUP_ANALYSIS_FILE_EXTENSIONS=.png,.jpg,.jpeg
23+
- PY_IMAGE_DEDUP_ANALYSIS_THREADS=8
24+
- PY_IMAGE_DEDUP_ANALYSIS_USE_EXIF_DATA=True
25+
- PY_IMAGE_DEDUP_DEDUPLICATION_DUPLICATES_TARGET_DIRECTORY=/mnt/duplicates/
26+
- PY_IMAGE_DEDUP_ELASTICSEARCH_AUTO_CREATE_INDEX=True
27+
- PY_IMAGE_DEDUP_ELASTICSEARCH_HOST=elasticsearch
28+
- PY_IMAGE_DEDUP_ELASTICSEARCH_MAX_DISTANCE=0.1
29+
- PY_IMAGE_DEDUP_REMOVE_EMPTY_FOLDERS=False
30+
volumes:
31+
# change this to your local source directory
32+
- /mnt/sdb2/Sample:/mnt/source
33+
# change this to your local duplicates directory
34+
- /mnt/sdb2/py-image-dedup_duplicates:/mnt/duplicates
35+
links:
36+
- elasticsearch
37+
networks:
38+
- docker-elk
39+
depends_on:
40+
- elasticsearch
41+
restart: on-failure
42+
networks:
43+
docker-elk:
44+
driver: bridge

py_image_dedup/cli.py

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525

2626
@click.group(context_settings=CONTEXT_SETTINGS)
27+
@click.version_option()
2728
def cli():
2829
pass
2930

py_image_dedup/config.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
from datetime import timedelta
22

3-
from container_app_conf import ConfigBase, EnvSource, YamlSource
3+
from container_app_conf import ConfigBase
44
from container_app_conf.entry.bool import BoolConfigEntry
55
from container_app_conf.entry.file import DirectoryConfigEntry
66
from container_app_conf.entry.float import FloatConfigEntry
77
from container_app_conf.entry.int import IntConfigEntry
88
from container_app_conf.entry.list import ListConfigEntry
99
from container_app_conf.entry.string import StringConfigEntry
1010
from container_app_conf.entry.timedelta import TimeDeltaConfigEntry
11+
from container_app_conf.source.env_source import EnvSource
12+
from container_app_conf.source.yaml_source import YamlSource
1113

1214
NODE_MAIN = "py_image_dedup"
1315

py_image_dedup/persistence/elasticsearchstorebackend.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import time
23

34
import requests
45
from elasticsearch import Elasticsearch
@@ -40,8 +41,12 @@ def __init__(self,
4041
self.host = self.DEFAULT_DATABASE_HOST if host is None else host
4142
self.port = self.DEFAULT_DATABASE_PORT if port is None else port
4243

44+
detected_version = None
45+
while detected_version is None:
46+
time.sleep(2)
47+
detected_version = self._detect_db_version()
48+
4349
self._el_version = el_version
44-
detected_version = self._detect_db_version()
4550
if self._el_version is not None and detected_version is not None and self._el_version != detected_version:
4651
raise AssertionError(
4752
"Detected database version ({}) does not match expected version ({})".format(detected_version,
@@ -76,6 +81,7 @@ def __init__(self,
7681
{'host': self.host, 'port': self.port}
7782
]
7883
),
84+
el_version=self._el_version,
7985
index=self._el_index,
8086
doc_type=self._el_doctype,
8187
distance_cutoff=max_dist

requirements.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
setuptools
2-
container-app-conf>=3.0.0
2+
pip>=19.2.3
3+
container-app-conf>=3.0.2
34
requests
45
scipy
56
numpy
6-
image_match
7+
image_match @ git+https://github.com/markusressel/[email protected]#egg=image_match
78
elasticsearch>=6
89
tabulate
910
tqdm

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def read_requirements_file(file_name: str):
7373
tests_require=test_requirements(),
7474
entry_points={
7575
'console_scripts': [
76-
'py-image-dedup=py_image_dedup.cli.Main:cli'
76+
'py-image-dedup = py_image_dedup.cli:cli'
7777
]
7878
}
7979
)

0 commit comments

Comments
 (0)