ERPNext on a Raspberry Pi 3 with Debian 9

Hi @webingold2 I noticed you added a Wiki Page but it directs to a remote link. It’d be nice if you create one instead of a redirect. Thanks!

Unfortunately, I don’t know how to do this, that is why I used an external link! :grinning:

hi, i do the same job to you and faced the same error.

I posted my worked solution at [Can’t install chromedriver] for your reference.

Thanks for sharing your guide @webingold2, it was very helpful. I’ve been trying to install ERPNext in my Raspberry Pi 3 for about 3 days before I found this.

For those who will come across this post later, I can confirm that the installation procedure linked in the opening post above, completed successfully in the Nov 2017 release of Raspbian Stretch Lite. Latest releases are available here. And older releases, here.

That is, if you don’t apt upgrade anymore, which is what I did. I find that these updates are causing more problems than applying fixes. :smile:

Aside from the apt upgrade part, there was also a typo in @webingold2’s shell script above, which caused a minor error. For the convenience of others who will later come to this thread, below is the easy-to-copy-paste and working version of that script (most of the comments stripped away):

#!/bin/sh
#
#
#
USERNAME='frappe'
USERPWD='frappe'
YOURSITENAME='erpnext.raspberrypi.local'
MARIADBPWD='mariadbpass'

# just to measure the lapsed time:
TT() {
    STEPEND=$(date +%s)
    STEPDIFF=$((STEPEND-STEPSTART))
    TOTALDIFF=$((STEPEND-START))
    echo "${1} duration is ${STEPDIFF} seconds. Total time now is ${TOTALDIFF} seconds."
    echo "${1} duration is ${STEPDIFF} seconds. Total time now is ${TOTALDIFF} seconds." >> time.txt
    STEPSTART=$(date +%s)
}

START=$(date +%s)
STEPSTART=$(date +%s)
echo "Summary of durations" > time.txt

sudo adduser --quiet --disabled-password --shell /bin/bash --home /home/$USERNAME --gecos "$USERNAME" $USERNAME
echo "$USERPWD\n$USERPWD\n" | sudo passwd $USERNAME
sudo usermod -aG sudo $USERNAME
TT "3.2. Create ''$USERNAME'' user"

sudo apt -y install build-essential software-properties-common dirmngr curl
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
TT "3.3. Install some basic packages"

sudo apt -y install mariadb-server
rm -f skdjfh.sql
cat > skdjfh.sql << EOF
use mysql;
update user set plugin='' where user='root';
update user set password=PASSWORD("$MARIADBPWD") where User='root';
flush privileges;
quit
EOF

sudo mysql -u root < skdjfh.sql
rm -f skdjfh.sql

rm -f skdjfh.cnf
cat > skdjfh.cnf << EOF

[mysqld]
innodb-file-format=barracuda
innodb-file-per-table=1
innodb-large-prefix=1
character-set-client-handshake=FALSE
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci

[mysql]
default-character-set=utf8mb4
EOF

cat skdjfh.cnf | sudo tee -a /etc/mysql/mariadb.conf.d/50-server.cnf > /dev/null
rm -f skdjfh.cnf
TT "3.4. Install MariaDB"

sudo curl -sL https://deb.nodesource.com/setup_7.x | sudo bash -
sudo apt -y install nodejs nginx redis-server wkhtmltopdf git-core python-pip libmariadbclient-dev python-mysqldb libssl-dev
sudo pip install --upgrade setuptools
sudo pip install MySQL-python --no-binary :all:
sudo apt -y install supervisor libffi-dev libjpeg-dev libxml2-dev libxslt1-dev
TT "3.5. Install few more packages"

rm -f skdjfh.sh
cat > skdjfh.sh << EOFB
#!/bin/sh
USERNAME='$USERNAME'
YOURSITENAME='$YOURSITENAME'
EOFB
cat >> skdjfh.sh << 'EOFB'

TT() {
    STEPEND=$(date +%s)
    STEPDIFF=$((STEPEND-STEPSTART))
    TOTALDIFF=$((STEPEND-START))
    echo "${1} duration is ${STEPDIFF} seconds. Total time now is ${TOTALDIFF} seconds."
    echo "${1} duration is ${STEPDIFF} seconds. Total time now is ${TOTALDIFF} seconds." >> time.txt
    STEPSTART=$(date +%s)
}

START=$(date +%s)
STEPSTART=$(date +%s)
echo "Summary of durations" > time.txt

sudo rm -rf bench-repo
sudo rm -rf frappe-bench
git clone https://github.com/frappe/bench bench-repo
sudo pip install -e bench-repo
bench init frappe-bench && cd frappe-bench
bench update
bench config http_timeout 600
yes | bench setup supervisor
yes | bench setup nginx
bench new-site $YOURSITENAME
TT "3.6. Install frappe and bench frameworks"

rm -f skdjfh.sh
cat > skdjfh.sh << 'EOFC'
#!/bin/sh
EOFC
cat >> skdjfh.sh << EOFC
USERNAME='$USERNAME'
YOURSITENAME='$YOURSITENAME'
EOFC
cat >> skdjfh.sh << 'EOFC'

TT() {
    STEPEND=$(date +%s)
    STEPDIFF=$((STEPEND-STEPSTART))
    TOTALDIFF=$((STEPEND-START))
    echo "${1} duration is ${STEPDIFF} seconds. Total time now is ${TOTALDIFF} seconds."
    echo "${1} duration is ${STEPDIFF} seconds. Total time now is ${TOTALDIFF} seconds." >> time.txt
    STEPSTART=$(date +%s)
}

START=$(date +%s)
STEPSTART=$(date +%s)
echo "Summary of durations" > time.txt

bench get-app erpnext https://github.com/frappe/erpnext
bench --site $YOURSITENAME install-app erpnext
bench config http_timeout 600
yes | bench setup supervisor
yes | bench setup nginx
sudo bench setup production $USERNAME
ip addr| grep "inet 192" | awk -F'[: ]+' '{ print $3 }'
TT "3.7. Configuration of ERPNext"
echo ""
echo "Your Raspberry Pi now is ready to run ERPNEXT!"
EOFC
EOFB
cat >> skdjfh.sh << EOFB
sudo mv skdjfh.sh /home/$USERNAME/frappe-bench/c.sh
sudo chmod +x /home/$USERNAME/frappe-bench/c.sh

echo ""
echo "The Raspberry Pi will now reboot in 5 seconds."
echo "Reconnect as $USERNAME user and go to the frappe-bench folder and run c.sh"
sleep 5s
sudo shutdown -r now
EOFB

sudo mv skdjfh.sh /home/$USERNAME/b.sh
sudo chmod +x /home/$USERNAME/b.sh

echo ""
echo "The Raspberry Pi will now reboot in 5 seconds."
echo "Reconnect as $USERNAME user and run b.sh."
sleep 5s
sudo shutdown -r now

For the rest of the steps, follow @webingold2’s guide here.

3 Likes

This guide is quite good and in detail.

I will try to get it working if I can.

Thanks.

Hi Prakhar, can you give me some more details?
I’m not able to get the traefik part working on the docker swam instructions in raspbian.

I really want to get this working on a raspberry pi.

Hi Mark, I just followed the instructions here for setting up traefic and it worked. If you are using the same instructions then there could be problems with generating certificates using lets-encrypt. What issue are you facing exactly?

Thanks! That was where I was using.
I can’t get the traefik website to load part way through the setup. I think I figured it out though. I set it up with a domain, but didn’t have a hosts file entry and then I messed up the IP address the second time.

So I’ll try again on the weekend. I’ll make a step by step guide if it ends up working. I tried to build using the single bench install before trying the docker swarm method, but got stuck on the phantomjs in frappe bench dependency as there isn’t a build for arm64 and the previous arm64 forks don’t compile on ubuntu 20/21 or raspbian’s current version.

I also ran into the PhantomJS issue. I found a workaround for that. If you want to build the images for arm64, take a look at the last few commits here -
https://github.com/Prakhar225/frappe_docker

2 Likes

Hi Prakhar, when your commit says “needs refactoring”
What are you meaning exactly?

Like making it up to date with the current builds?

Hi Mark, it says “need refactoring” because although it will work, it might not be the most optimized way to build that image. I kept on modifying the dockerfile until all the dependencies were resolved but I did not bother checking if everything I added in the previous steps was still needed. For example, you will find a line with the comment “This might not be needed”.

Also, in the following line, you will have to change the URL to the binary to build on arm64 as I have hardcoded the version -
https://github.com/Prakhar225/frappe_docker/blob/8f8f13ce62ae657ad55a09e67c2ab03de1e655d6/build/frappe-worker/Dockerfile#L48

It looks like it’s even easier to build the images now:

docker buildx bake -f docker-bake.hcl bench-build
docker buildx bake -f docker-bake.hcl frappe-develop
docker buildx bake -f docker-bake.hcl erpnext-develop

docker-compose --project-name up -d
worked without alteration on the latest develop branch

If you try to do them in parallel they fail, but doing them in order like that worked for me

Edit: Took about 2 hours on my pi to build the images

1 Like

Just out of curiosity. Is it possible to work on a system running on a Raspberry Pi? How slow are the response times on that? Or is this purely to test and play around with it?

It’s definitely possible to work on a raspberry Pi. The response times aren’t bad. The build and install is painful, but other than it’s fine. Prolly fine for up to 5 users or so.
Response times over a local network are just as fast as on my Intel Server.
As long as I don’t do super compute heavy tasks, I don’t see any issues.

1 Like

That’s quite impressive what does little computers can do.

We’re not officially building these for the same reason.
2 hour CI job is a problem, If something fails, fix is +2 hours away.

To be fair, it was a raspberry pi I was building it on. My desktop builds it in like 8 minutes. But I can’t figure out how to use docker desktop to build a linux/arm64 image that I can then send to my pi. I don’t use Docker in my day job so I’m a novice. I was just happy I could get it to work. Some instructions on the repo to actually make it work would be great as it was a long and very painful process to get to this point.

Even just how to build the images, the instructions are confusing on the Docker Images page.

amd64 build takes less time

No, I mean an arm64 builder using buildx. I only have a problem with the erpnext-nginx image. For some reason the install_app.sh script doesn’t work.