Install Backup module in RPi docker container

Hello,

I’m running EmonCMS in docker image some time, installed by these 4 simple step in emoncms-docker repo.

Trying to add backup module.
Added these lines to my /home/pi/emoncms-docker/web/Dockerfile

# Adding EmonCMS Scripts
RUN git clone https://github.com/openenergymonitor/EmonScripts.git /opt/openenergymonitor

# Adding backup module
RUN git clone https://github.com/emoncms/backup.git /var/www/emoncms/Modules/backup
RUN /var/www/emoncms/Modules/backup/install.sh

Building new web container with

 docker-compose up --build -d  web

but getting several errors and compile is not succesfull.

Problems with sudo in install.sh script i tried with adding

RUN echo "#!/bin/bash\n\$@" > /usr/bin/sudo
RUN chmod +x /usr/bin/sudo```

but still getting errors with eg symlink, i do not see variables echoed in script and so on.

Here is the log from the build

pi@raspberrypi:~/emoncms-docker $ docker-compose up --build -d  web
Building web
[+] Building 4.0s (29/39)
 => [internal] load build definition from Dockerfile                                                                  0.1s
 => => transferring dockerfile: 2.86kB                                                                                0.0s
 => [internal] load .dockerignore                                                                                     0.2s
 => => transferring context: 2B                                                                                       0.0s
 => [internal] load metadata for docker.io/library/php:8.0-apache                                                     0.7s
 => [internal] load build context                                                                                     0.1s
 => => transferring context: 259B                                                                                     0.0s
 => [ 1/35] FROM docker.io/library/php:8.0-apache@sha256:384e185e8d7e02e86e9e815750b5e454da36c9a7961f0a6c2b0da74e338  0.0s
 => CACHED [ 2/35] RUN echo "#!/bin/bash\n$@" > /usr/bin/sudo                                                         0.0s
 => CACHED [ 3/35] RUN chmod +x /usr/bin/sudo                                                                         0.0s
 => CACHED [ 4/35] RUN apt-get update && apt-get install -y               libcurl4-gnutls-dev               libmcryp  0.0s
 => CACHED [ 5/35] RUN docker-php-ext-install -j$(nproc) mysqli gettext                                               0.0s
 => CACHED [ 6/35] COPY install_redis.sh /                                                                            0.0s
 => CACHED [ 7/35] RUN chmod +x /install_redis.sh                                                                     0.0s
 => CACHED [ 8/35] RUN /install_redis.sh                                                                              0.0s
 => CACHED [ 9/35] COPY install_mosquitto.sh /                                                                        0.0s
 => CACHED [10/35] RUN chmod +x /install_mosquitto.sh                                                                 0.0s
 => CACHED [11/35] RUN /install_mosquitto.sh                                                                          0.0s
 => CACHED [12/35] RUN a2enmod rewrite                                                                                0.0s
 => CACHED [13/35] COPY config/php.ini /usr/local/etc/php/                                                            0.0s
 => CACHED [14/35] COPY config/emoncms.conf /etc/apache2/sites-available/emoncms.conf                                 0.0s
 => CACHED [15/35] RUN a2dissite 000-default.conf                                                                     0.0s
 => CACHED [16/35] RUN a2ensite emoncms                                                                               0.0s
 => CACHED [17/35] RUN mkdir /var/www/emoncms                                                                         0.0s
 => CACHED [18/35] RUN git clone https://github.com/emoncms/emoncms.git /var/www/emoncms                              0.0s
 => CACHED [19/35] RUN git clone https://github.com/emoncms/dashboard.git /var/www/emoncms/Modules/dashboard          0.0s
 => CACHED [20/35] RUN git clone https://github.com/emoncms/graph.git /var/www/emoncms/Modules/graph                  0.0s
 => CACHED [21/35] RUN git clone https://github.com/emoncms/app.git /var/www/emoncms/Modules/app                      0.0s
 => CACHED [22/35] RUN git clone https://github.com/emoncms/device.git /var/www/emoncms/Modules/device                0.0s
 => CACHED [23/35] RUN git clone https://github.com/openenergymonitor/EmonScripts.git /opt/openenergymonitor          0.0s
 => CACHED [24/35] RUN git clone https://github.com/emoncms/backup.git /var/www/emoncms/Modules/backup                0.0s
 => ERROR [25/35] RUN /var/www/emoncms/Modules/backup/install.sh       2.9s
------
 > [25/35] RUN /var/www/emoncms/Modules/backup/install.sh:
#0 1.522 - EmonScripts config.ini not found, starting manual process
#0 1.523   
#0 1.524    valid
#0 1.525    valid
#0 1.525    valid
#0 1.527 - Copying default.config.cfg to config.cfg
#0 1.541 - Setting config.cfg settings
#0 1.638 - symlinking backup module
#0 1.645 ln: failed to create symbolic link '/var/www/emoncms/Modules/backup/backup-module': File exists
#0 1.778 - creating /etc/php/8.0/mods-available/emoncmsbackup.ini
#0 1.794 tee: /etc/php/8.0/mods-available/emoncmsbackup.ini: No such file or directory
#0 1.795 post_max_size = 3G
#0 1.795 upload_max_filesize = 3G
#0 1.795 upload_tmp_dir = /backup/uploads
#0 1.799 - phpenmod emoncmsbackup
#0 1.812 /usr/bin/sudo: line 2: phpenmod: command not found
#0 1.817 - creating /backup directory
#0 1.850 chown: invalid user: 'pi:pi'
#0 1.853 - creating /backup/uploads directory
#0 1.885 chown: invalid group: 'www-data:pi'
#0 1.888 - restarting apache
#0 1.934 Restarting Apache httpd web server: apache2 failed!
#0 2.185 The apache2 configtest failed. ... (warning).
#0 2.191 Output of config test was:
#0 2.194 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
#0 2.194 (2)No such file or directory: AH02291: Cannot access directory '/var/log/emoncms/' for error log of vhost defined at /etc/apache2/sites-enabled/emoncms.conf:1
#0 2.194 AH00014: Configuration check failed
#0 2.194 Action 'configtest' failed.
#0 2.194 The Apache error log may have more information.
------
Dockerfile:61
--------------------
  59 |     #RUN export xargs --null --max-args=1 echo < /proc/1/environ
  60 |     #RUN chmod +x /var/www/emoncms/Modules/backup/install.sh
  61 | >>> RUN /var/www/emoncms/Modules/backup/install.sh
  62 |
  63 |     COPY docker.settings.ini /var/www/emoncms/settings.ini
--------------------
ERROR: failed to solve: process "/bin/sh -c /var/www/emoncms/Modules/backup/install.sh" did not complete successfully: exit code: 1
ERROR: Service 'web' failed to build : Build failed

Config of my system:

pi@raspberrypi:~ $ hostnamectl
   Static hostname: raspberrypi
         Icon name: computer
        Machine ID: aa752e1409014381a3b424b96bf89d85
           Boot ID: 7a799e9c7d6848e194209a06912ce395
  Operating System: Debian GNU/Linux 11 (bullseye)
            Kernel: Linux 6.1.21-v8+
      Architecture: arm64

Appreciate any help… thank you in advance.

I am actually working on containers for the emoncms stack with everything running in a single container, and backup module is included.

Check this :

Maybe it can be interesting for you

There is an arm64 image online :

docker pull alexjunk/emoncms:0.0.3.arm64v8