From 80df9a30253056b54b29ed4158df8f454a85f167 Mon Sep 17 00:00:00 2001 From: Amit Sides Date: Fri, 6 Jan 2023 01:21:18 +0200 Subject: [PATCH 1/5] Changed config to volume --- config.example.json | 8 -------- docker-compose.yml | 3 ++- docker-compose.yml.example-second-dashboard | 3 ++- 3 files changed, 4 insertions(+), 10 deletions(-) delete mode 100644 config.example.json diff --git a/config.example.json b/config.example.json deleted file mode 100644 index 67721f6..0000000 --- a/config.example.json +++ /dev/null @@ -1,8 +0,0 @@ -// Copy this file to config.json in the root folder -// supported: binance_futures, bybit_derivatives (NOTE: USDT_Perpetual only) - -{ - "exchange": "binance_futures", - "api_key": "", - "api_secret": "", - } diff --git a/docker-compose.yml b/docker-compose.yml index 11b06e3..b856cce 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: From 37fe0d70a845097ca7bf97618564def169ad364c Mon Sep 17 00:00:00 2001 From: Amit Sides Date: Fri, 6 Jan 2023 01:21:31 +0200 Subject: [PATCH 2/5] Better image building --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8d90339..32c7887 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,12 @@ # syntax=docker/dockerfile:1 FROM python:3.8.7-alpine -COPY scraper_root /scraper/scraper_root + RUN apk add --no-cache gcc musl-dev linux-headers libffi-dev g++ RUN pip install --upgrade pip + +COPY scraper_root /scraper/scraper_root RUN pip install -r /scraper/scraper_root/requirements.txt -COPY config*.json /scraper/ + WORKDIR /scraper ENV PYTHONPATH "${PYTHONPATH}:/scraper" CMD ["python3", "scraper_root/scraper.py"] \ No newline at end of file From 35b0fa1c6e2f48499b714e7fb0fa3cd62ba09792 Mon Sep 17 00:00:00 2001 From: Amit Sides Date: Fri, 6 Jan 2023 01:27:49 +0200 Subject: [PATCH 3/5] Even better image building --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 32c7887..9d4ddc8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,9 +4,11 @@ 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 scraper_root /scraper/scraper_root + WORKDIR /scraper ENV PYTHONPATH "${PYTHONPATH}:/scraper" CMD ["python3", "scraper_root/scraper.py"] \ No newline at end of file From 99568ef6ca3ab3515b15f68c6a7805aaec4b34f5 Mon Sep 17 00:00:00 2001 From: Amit Sides Date: Fri, 6 Jan 2023 13:31:58 +0200 Subject: [PATCH 4/5] Changed default config path --- config.example.json | 19 ------------------- scraper_root/scraper.py | 2 +- 2 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 config.example.json diff --git a/config.example.json b/config.example.json deleted file mode 100644 index 2455014..0000000 --- a/config.example.json +++ /dev/null @@ -1,19 +0,0 @@ -// Copy this file to config.json in the root folder -// supported: binance_futures, bybit_derivatives (NOTE: USDT_Perpetual only) - -{ - "accounts": [ - { - "alias": "demo_1", - "exchange": "binance_futures", - "api_key": "", - "api_secret": "" - }, - { - "alias": "demo_2", - "exchange": "binance_futures", - "api_key": "", - "api_secret": "" - } - ] -} 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)) From ea21a627780daa89dc031f95d5ee5f956c51b6d4 Mon Sep 17 00:00:00 2001 From: Amit Sides Date: Fri, 6 Jan 2023 13:34:51 +0200 Subject: [PATCH 5/5] Removed ignored example --- .gitignore | 1 + config/config.example.json | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 config/config.example.json 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/config/config.example.json b/config/config.example.json new file mode 100644 index 0000000..2455014 --- /dev/null +++ b/config/config.example.json @@ -0,0 +1,19 @@ +// Copy this file to config.json in the root folder +// supported: binance_futures, bybit_derivatives (NOTE: USDT_Perpetual only) + +{ + "accounts": [ + { + "alias": "demo_1", + "exchange": "binance_futures", + "api_key": "", + "api_secret": "" + }, + { + "alias": "demo_2", + "exchange": "binance_futures", + "api_key": "", + "api_secret": "" + } + ] +}