diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d12d7b3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +/.vagrant +/scrapy.iml +*.pyc +_trial_temp* +dropin.cache +docs/build +*egg-info +.tox +venv +build +dist +.idea +htmlcov/ +.coverage +.pytest_cache/ +.coverage.* +.cache/ + +# Windows +Thumbs.db \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..44789d4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM alpine:3.9 + +ENV RUNTIME_PACKAGES python3 libxslt libxml2 git curl +ENV BUILD_PACKAGES build-base libxslt-dev libxml2-dev libffi-dev python3-dev openssl-dev + +RUN apk add --no-cache ${RUNTIME_PACKAGES} ${BUILD_PACKAGES} && \ + pip3 install scrapy && \ + apk del ${BUILD_PACKAGES} && \ + rm -rf /root/.cache + +#ADD ./scrapyd.conf /etc/scrapyd/ +#VOLUME /var/lib/scrapyd/ + +COPY . /work/app +RUN pip3 install -r /work/app/requirements.txt +RUN /usr/bin/crontab /work/app/install/crontab.txt +CMD ["/usr/sbin/crond", "-f", "-l", "8"] \ No newline at end of file diff --git a/coinincome/settings.py b/coinincome/settings.py index 72a6b26..98c2e82 100644 --- a/coinincome/settings.py +++ b/coinincome/settings.py @@ -8,6 +8,7 @@ # https://doc.scrapy.org/en/latest/topics/settings.html # https://doc.scrapy.org/en/latest/topics/downloader-middleware.html # https://doc.scrapy.org/en/latest/topics/spider-middleware.html +import os BOT_NAME = 'coinincome' @@ -89,7 +90,7 @@ # HTTPCACHE_IGNORE_HTTP_CODES = [] # HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage' -MYSQL_HOST = "127.0.0.1" -MYSQL_DBNAME = "pool_coin_income" -MYSQL_USER = "root" -MYSQL_PASSWORD = "" +MYSQL_HOST = os.getenv('MYSQL_HOST', '127.0.0.1') +MYSQL_DBNAME = os.getenv('MYSQL_DBNAME', 'pool_coin_income') +MYSQL_USER = os.getenv('MYSQL_USER', 'root') +MYSQL_PASSWORD = os.getenv('MYSQL_PASSWORD', 'root') diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..882ee1b --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,12 @@ +# at https://docs.docker.com/compose/compose-file/ +version: '3.3' +services: + scrapy-pool-incomes: + container_name: scrapy-pool-income + image: dubuqingfeng/scrapy-pool-income + restart: always + environment: + MYSQL_HOST: "production" + MYSQL_DBNAME: "" + MYSQL_USER: "" + MYSQL_PASSWORD: "" \ No newline at end of file diff --git a/install/crontab.txt b/install/crontab.txt new file mode 100644 index 0000000..8552192 --- /dev/null +++ b/install/crontab.txt @@ -0,0 +1 @@ +*/5 * * * * cd /work/app && sh /work/app/run.sh \ No newline at end of file