diff --git a/.gitignore b/.gitignore index 04709cd..64f8cb9 100644 --- a/.gitignore +++ b/.gitignore @@ -130,6 +130,7 @@ dmypy.json /data *.json +!*.example.json *.db.trace.db diff --git a/Dockerfile b/Dockerfile index 9a41e48..9d4ddc8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,14 @@ # syntax=docker/dockerfile:1 FROM python:3.8.7-alpine + RUN apk add --no-cache gcc musl-dev linux-headers libffi-dev g++ RUN pip install --upgrade pip -COPY scraper_root /scraper/scraper_root + +COPY scraper_root/requirements.txt /scraper/scraper_root/requirements.txt RUN pip install -r /scraper/scraper_root/requirements.txt -COPY config*.json /scraper/ + +COPY scraper_root /scraper/scraper_root + WORKDIR /scraper ENV PYTHONPATH "${PYTHONPATH}:/scraper" CMD ["python3", "scraper_root/scraper.py"] \ No newline at end of file diff --git a/config.example.json b/config/config.example.json similarity index 100% rename from config.example.json rename to config/config.example.json diff --git a/docker-compose.yml b/docker-compose.yml index 63e163d..bd8a88b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,10 +3,11 @@ services: scraper: build: . environment: - - CONFIG_FILE=/scraper/config.json + - CONFIG_FILE=/config/config.json - DATABASE_PATH=sqlite:////data/exchanges_db.sqlite volumes: - $PWD/data:/data + - $PWD/config:/config - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro metabase-app: diff --git a/docker-compose.yml.example-second-dashboard b/docker-compose.yml.example-second-dashboard index 2dd7a71..0077d80 100644 --- a/docker-compose.yml.example-second-dashboard +++ b/docker-compose.yml.example-second-dashboard @@ -3,10 +3,11 @@ services: scraper2: build: . environment: - - CONFIG_FILE=/scraper/config.json + - CONFIG_FILE=/config/config.json - DATABASE_PATH=sqlite:////data/exchanges_db.sqlite volumes: - $PWD/data:/data + - $PWD/config:/config - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro metabase-app2: diff --git a/scraper_root/scraper.py b/scraper_root/scraper.py index 31b0fc5..21dcd2f 100644 --- a/scraper_root/scraper.py +++ b/scraper_root/scraper.py @@ -19,7 +19,7 @@ logger = logging.getLogger() if __name__ == '__main__': - config_file_path = os.environ.get('CONFIG_FILE', 'config.json') + config_file_path = os.environ.get('CONFIG_FILE', '/config/config.json') logger.info(f"Using config file {config_file_path}") with open(config_file_path) as config_file: user_config = hjson.load(config_file, object_hook=lambda d: SimpleNamespace(**d))