diff --git a/doc/2.docker.md b/doc/2.docker.md index a7adde2..96b2bad 100644 --- a/doc/2.docker.md +++ b/doc/2.docker.md @@ -20,19 +20,32 @@ docker build -t phyks/flatisfy . mkdir flatisfy cd flatisfy FLATISFY_VOLUME=$(pwd) -docker run -P -v $FLATISFY_VOLUME:/flatisfy -p 8080:8080 phyks/flatisfy sh -c "cd /home/user/app && python -m flatisfy init-config > /flatisfy/config.json" +docker run -it -v $FLATISFY_VOLUME:/flatisfy phyks/flatisfy sh -c "cd /home/user/app && python -m flatisfy init-config > /flatisfy/config.json" ``` -3\. Then, edit the generated `config.json` file according to your needs. See +3\. Then, edit the generated `$FLATISFY_VOLUME/config.json` file according to your needs. See [0.getting_started.md](0.getting_started.md) for more infos on the - configuration file format. + configuration file format. You will have to define your constraints (at + least postal codes, house type and type of post), set `data_directory` to + `/flatisfy` and set `host` to `0.0.0.0` to make the web UI accessible from + outside the Docker container. The rest is up to you. 4\. Finally, run the docker image to fetch flats and serve the web UI: ``` -docker run -P -v $FLATISFY_VOLUME:/flatisfy -p 8080:8080 phyks/flatisfy +docker run -it -v $FLATISFY_VOLUME:/flatisfy -p 8080:8080 phyks/flatisfy ``` Your Flatisfy instance is now available at `localhost:8080`! + + +To fetch new housing posts, you should manually call + +``` +docker run -it -v $FLATISFY_VOLUME:/flatisfy phyks/flatisfy /home/user/fetch.sh +``` + +This can be done easily in a crontask on your host system, to run it typically +every night. diff --git a/docker/Dockerfile b/docker/Dockerfile index d8811ca..a50ddb0 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,8 +1,6 @@ FROM python:2 MAINTAINER Phyks -ENV LANG C.UTF-8 - # Setup layout. RUN useradd -d /home/user -m -s /bin/bash -U user @@ -39,12 +37,12 @@ RUN cd /home/user \ RUN chown user:user -R /home/user RUN mkdir -p /home/user/.local/share/flatisfy -COPY ./docker_run.sh /home/user/run.sh +COPY ./run.sh /home/user/run.sh RUN chmod +x /home/user/run.sh +COPY ./fetch.sh /home/user/fetch.sh +RUN chmod +x /home/user/fetch.sh # Run server. USER user - CMD /home/user/run.sh - EXPOSE 8080 diff --git a/docker/docker_run.sh b/docker/docker_run.sh deleted file mode 100644 index ffeb386..0000000 --- a/docker/docker_run.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -cd /home/user/app - -python -m flatisfy build-data -v --config /flatisfy/config.json - -# Run the server in the background. -python -m flatisfy serve --config /flatisfy/config.json & - -while true; -do - cd /home/user/weboob - git pull - - cd /home/user/app - python -m flatisfy import -v --config /flatisfy/config.json - - echo "Done, sleeping for 30 minutes." - sleep 1800 -done diff --git a/docker/fetch.sh b/docker/fetch.sh new file mode 100644 index 0000000..cd0e904 --- /dev/null +++ b/docker/fetch.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +echo "Updating Weboob..." +cd /home/user/weboob +git pull +pip install . + +echo "Fetching housing posts..." +cd /home/user/app +python -m flatisfy import -v --config /flatisfy/config.json diff --git a/docker/run.sh b/docker/run.sh new file mode 100644 index 0000000..37571b5 --- /dev/null +++ b/docker/run.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +echo "Setting fake values for git config..." +git config --global user.email flatisfy@example.com +git config --global user.name "Flatisfy Root" + +echo "Building data for Flatisfy..." +cd /home/user/app +python -m flatisfy build-data -v --config /flatisfy/config.json + +echo "Fetching new housing posts..." +/home/user/fetch.sh + +echo "Starting web UI..." +python -m flatisfy serve --config /flatisfy/config.json