Working on migrating my data from emoncms.org to a docker container on my nas. I have the container up and running with docker compose (GitHub - emoncms/emoncms-docker: Emoncms docker container(s)), but I dont see it having the sync module. What would be the steps to get this added in?
Hi Ben, the sync module is not as staightforward to install as the graph or dashboard modules. The Sync module requires cloning to a location outside of the /var/www path and then a sub-folder of that repo is symlinked into emoncms/Modules. There are also some other requirements to make this module work such as a “service-runner.sh” script (part of the emonpi repo not currently standalone) and a cron job to constantly check for emoncms flags to trigger that service-runner.sh.
ok in that case the solution is probably going to require use of crond and/or supervisord in the container in order to use the service-runner.sh . Or it needs a separate container. All the Docker stuff needs overhauling anyway so I might have a look when I try that.
After spending two nights trying to get this working for myself and trying to wrap my head around docker, this seems to be the simplest solution:
Edit the Dockerfile and add following lines (in place of that one line that @beaylott suggested):
RUN git clone https://github.com/emoncms/sync.git /home/pi/sync
RUN chgrp www-data /home/pi
RUN chgrp -R www-data /home/pi/sync
RUN ln -s /var/www/html /var/www/emoncms
RUN ln -s /home/pi/sync/sync-module /var/www/emoncms/Modules/sync
The reason I decided to place it in /home/pi even though there is no pi user is because that is the default location for $HOMEDIR on which the sync depends and it will save one step of modifying the settings.php. The other reason was that putting in /root did not seem right and would require modifying access rights to /root.
after you save the file, you will need to rebuild the container:
sudo docker-compose up -d --build
reload the webpage. At least use Ctrl+F5 if not close and reopen the tab.
Before you try to use Sync. Go to Setup->Administration and do Update&Check to update the database.
Follow the instructions on Sync git page on how to configure it.
Now comes the biggest caveat: I spend about 6 hours researching how to implement cron in docker. And although it is possible, it would over complicate things beyond simple instructions if implemented correctly. That leaves two options:
if you are just trying to transfer data from emoncms.org and this a one time deal, you can run the download manually by getting into the container using
if you want to do this on schedule, you can create a cron job on your host that executes that script inside the container. I have not done it myself but the crontab should look something like this
* * * * * docker run --rm emoncmsdocker_web_1 /home/pi/sync/emoncms-sync.sh