In py2 version, `COPY . /root` was placed after `RUN apk ...`, so that the result of `RUN apk ...` can be cached by Docker.
In py3 version, the commands were reordered to make the file `/root/requirements.txt` available for `pip install`. That prevents caching, and the docker image every time is rebuild from scrach.
To enable the caching back again, we can `COPY` just the single file `requirements.txt` before running other commands. Since the file is unmodified most of the time, the resulting image can be effectively cached. The other ZeroNet files are copied after doing `RUN apk ...`, as in the previous version.
Update to Alpine 3.8
Apply best practices eg:
- Don't upgrade
- Add --no-cache-dir to pip install
- Remove removing of any tmp folder as it is deprecated
- Format RUN block nicer
In order to keep the Dockerfile simple, needed opotions have been appended to package provided torrc file and the /etc/init.d/tor script is used to start tor. If further customisation is desired, a wrapper script should be created to have further control on the startup. This would allow things like specifying external (tor) proxies and disable tor startup in those situations.