Added docker support

This commit is contained in:
Javier Legido 2019-10-15 14:45:51 +02:00
parent aee7adceae
commit 1cedbc2549
5 changed files with 83 additions and 0 deletions

6
.env.example Normal file
View file

@ -0,0 +1,6 @@
NETWORK_EMAIL_EXTRACTOR=network-email-extractor
APP_NAME=email-extractor
APP_IMAGE=python
APP_IMAGE_LOCAL=localhost
APP_VERSION=3.7.4-buster

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
Emails.db
.google-cookie
/venv
*env

15
Dockerfile Normal file
View file

@ -0,0 +1,15 @@
ARG IMAGE
ARG VERSION
FROM $IMAGE:$VERSION
# IMPORTANT: remeber to declare ARG values AFTER FROM sentence....
MAINTAINER info@kedu.coop
ADD requirements.txt .
ADD EmailExtractor.py .
RUN pip install -r requirements.txt

View file

@ -38,3 +38,44 @@ pip install -r requirements.txt
[Extraer correos de paginas web con Python](http://www.pythondiario.com/2018/04/extraer-correos-electronicos-de-paginas.html)
## Docker
Docker and docker-compose are required.
In order to use docker follow below instructions:
### Installation
1. Get an .env file
```
cp .env.example .env
```
2. Start docker container
```
docker-compose up -d --build
```
### Usage
To execute the script and get the options menu:
```
docker exec -ti email-extractor python EmailExtractor.py
```
To get the sqlite db with al e-mails:
```
docker cp email-extractor:Emails.db .
```
To get the file saved, for instance, as "out":
```
ocker cp email-extractor:out.txt .
```

20
docker-compose.yaml Normal file
View file

@ -0,0 +1,20 @@
version: '3.7'
services:
email-extractor:
container_name: ${APP_NAME}
image: ${APP_IMAGE_LOCAL}/${APP_NAME}:${APP_VERSION}
networks:
- ${NETWORK_EMAIL_EXTRACTOR}
build:
context: .
args:
- IMAGE=${APP_IMAGE}
- VERSION=${APP_VERSION}
stdin_open: true
tty: true
networks:
network-email-extractor:
name: ${NETWORK_EMAIL_EXTRACTOR}