Skip to content

Commit ad41dc1

Browse files
committed
update docker support
1 parent 6a51783 commit ad41dc1

File tree

6 files changed

+28
-29
lines changed

6 files changed

+28
-29
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dev/
2+
ebooks/

Dockerfile

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
FROM python:2.7
22

3-
MAINTAINER Martin Kuchynar <[email protected]>
3+
WORKDIR /packtpub-crawler
44

5-
COPY requirements.txt /requirements.txt
6-
RUN pip install -r /requirements.txt
5+
COPY script script
6+
COPY config config
7+
COPY requirements.txt requirements.txt
78

8-
ADD entrypoint.sh /
9-
RUN chmod +x /entrypoint.sh
9+
RUN pip install -r requirements.txt
1010

11-
ENTRYPOINT ["/entrypoint.sh"]
12-
13-
CMD [ "/bin/bash" ]
11+
CMD ["python", "/packtpub-crawler/script/spider.py --config config/prod.cfg"]

readme.md renamed to README.md

+19-9
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,29 @@ More info about Heroku [Scheduler](https://devcenter.heroku.com/articles/schedul
178178

179179
### Docker setup [TODO](https://github.com/niqdev/packtpub-crawler/issues/18)
180180

181-
* Install docker and docker-compose
182-
* Clone the repository `git clone https://github.com/niqdev/packtpub-crawler.git`
183-
* Create a [config](https://github.com/niqdev/packtpub-crawler/blob/master/config/prod_example.cfg) file `cp config/prod_example.cfg config/prod.cfg`
184-
* Change your Packtpub credentials in the config file
181+
Build your image
185182
```
186-
[credential]
187-
credential.email=PACKTPUB_EMAIL
188-
credential.password=PACKTPUB_PASSWORD
183+
docker build -t niqdev/packtpub-crawler:1.3.0 .
189184
```
190185

191-
Now you should be able to claim and download your first eBook
186+
Run manually
187+
```
188+
docker run \
189+
--rm \
190+
--name my-packtpub-crawler \
191+
niqdev/packtpub-crawler:1.3.0 \
192+
python script/spider.py --config config/prod.cfg --upload drive
192193
```
193-
docker-compose run packtpub-crawler --config config/prod.cfg
194+
195+
TODO
196+
Run schedule daily job
197+
```
198+
docker run \
199+
--detach \
200+
--name my-packtpub-crawler \
201+
niqdev/packtpub-crawler:1.3.0
202+
203+
docker exec -i -t my-packtpub-crawler bash
194204
```
195205

196206
### Development (only for spidering)

docker-compose.yml

-7
This file was deleted.

entrypoint.sh

-4
This file was deleted.

script/spider.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def main():
1616
parser = argparse.ArgumentParser(
1717
description='Download FREE eBook every day from www.packtpub.com',
1818
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
19-
version='1.2.0')
19+
version='1.3.0')
2020

2121
parser.add_argument('-c', '--config', required=True, help='configuration file')
2222
parser.add_argument('-d', '--dev', action='store_true', help='only for development')

0 commit comments

Comments
 (0)