loomio / loomio-deploy

Install Loomio on your own server
147 stars 60 forks source link

Trying to deploy on an armv7l server (raspbian/raspberry pi4) #68

Closed jimaldon closed 1 year ago

jimaldon commented 4 years ago

Deployment runs until I run the following command

$ docker-compose --verbose run app rake db:setup

I get the error standard_init_linux.go:211: exec user process caused "exec format error"

I understand it's because the loomio:loomio/stable docker image is built for linux/amd64. Is there an arm version planned? If not, are there any roadblocks to building it for arm?

robguthrie commented 4 years ago

Hi, yes Loomio should run on ARM, but the docker images are compiled for amd64.

To build for ARM: Checkout this repo (loomio/loomio-deploy) then inside it, check out the loomio/loomio repo into a directory called loomio.

cd loomio-deploy
git clone git@github.com:loomio/loomio.git
cd loomio
git checkout stable
cd ..

Then edit the docker-compose.yml file and comment out (with a # symbol) lines 30 and 51, (the lines which say image: ...) and insert a new line. So it looks a bit like this:

app:
  container_name: loomio-app
  restart: always
  # image: ${LOOMIO_CONTAINER_IMAGE}:${LOOMIO_CONTAINER_TAG}
  build: ./loomio

...

worker:
  container_name: loomio-worker
  restart: always
  # image: ${LOOMIO_CONTAINER_IMAGE}:${LOOMIO_CONTAINER_TAG}
  build: ./loomio

Docker will then build a custom ARM image for you. If you need to upgrade loomio, run

cd loomio-deploy/loomio
git pull origin stable
cd ..
docker-compose build

The rest of the upgrade instructions in the README still apply (running migrations etc, shutting down, starting up etc)

jimaldon commented 4 years ago

Thanks! That helped.

I ran into a problem with bcrypt gem dependency on arm (https://github.com/codahale/bcrypt-ruby/issues/201) I fixed that by changing L122 in Gemfile.lock from bcrypt (3.1.13) to bcrypt (3.1.12) which seemed to fix the issue.

I then ran into another problem further on building the app, possibly with loomio/vue:

Step 22/27 : WORKDIR /loomio/vue
 ---> Running in 8fe795052ff1
Removing intermediate container 8fe795052ff1
 ---> 586a7cc1edbb
Step 23/27 : RUN npm install
 ---> Running in af403feeeb79

> chromedriver@2.46.0 install /loomio/vue/node_modules/@vue/cli-plugin-e2e-nightwatch/node_modules/chromedriver                                                                                                   
> node install.js

Only Linux 64 bits supported.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})                                                 

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chromedriver@2.46.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the chromedriver@2.46.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-05-10T00_54_21_639Z-debug.log
ERROR: Service 'app' failed to build: The command '/bin/sh -c npm install' returned a non-zero code: 1
robguthrie commented 4 years ago

Nice work.

I've just added --only=production to the npm install command in the Dockerfile, but it's on the master branch right now.

That should skip chromedriver install

robguthrie commented 4 years ago

Hrrmm, that was a bad idea, I've undone it. I think I need some advice on how to install or configure the packages so chromedriver is not installed when it isn't required.

jimaldon commented 4 years ago

Yeah I tried the --only=production on master and I got the following error:

Step 23/27 : RUN npm install --only=production
 ---> Running in 0c429bec092d

> core-js@2.6.11 postinstall /loomio/vue/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

added 210 packages from 481 contributors and audited 33682 packages in 47.832s
found 942 vulnerabilities (933 low, 8 high, 1 critical)
  run `npm audit fix` to fix them, or `npm audit` for details
Removing intermediate container 0c429bec092d
 ---> d16ec46a8cca
Step 24/27 : RUN npm run build
 ---> Running in 7c1866f5bc52

> vue@0.1.0 build /loomio/vue
> vue-cli-service build --modern

sh: 1: vue-cli-service: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! vue@0.1.0 build: `vue-cli-service build --modern`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the vue@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-05-10T04_08_56_456Z-debug.log
ERROR: Service 'app' failed to build: The command '/bin/sh -c npm run build' returned a non-zero code: 1
robguthrie commented 4 years ago

You could try a npm install -g vue-cli-service (global install)

Maybe the change for the Dockerfile is make all the stuff that we need to build production but is a devDep global installed instead?

jimaldon commented 4 years ago

So before I tried the global install, I just removed chromedriver and nightwatch from devDependencies and the build process seemed to work with no more errors.

However when I started the services with docker-compose up -d two containers kept restarting loomio-nginx and loomio-mailin

For the former, it uses linux/amd64 exclusive dockerimage from jwilder/nginx-proxy and I'm trying to find alternatives for arm64/aarch64 Any ideas for this or loomio-mailin on aarch64?

jimaldon commented 4 years ago

UPDATE

I cloned in the repos for the two offending docker containers and replaced image: with build: like how you mentioned with loomio above https://github.com/loomio/mailin-docker.git https://github.com/nginx-proxy/nginx-proxy

Like before, the build completes but when I try and start the services with docker-compose up -d`, I get the following error withloomio-mailin`

Setting up spamassassin (3.4.2-1~deb9u3) ...
Adding system user `debian-spamd' (UID 101) ...
Adding new group `debian-spamd' (GID 102) ...
Adding new user `debian-spamd' (UID 101) with group `debian-spamd' ...
Not creating home directory `/var/lib/spamassassin'.
su: Critical error - immediate abort
dpkg: error processing package spamassassin (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of sa-compile:
 sa-compile depends on spamassassin; however:
  Package spamassassin is not configured yet.

dpkg: error processing package sa-compile (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 spamassassin
 sa-compile

For reference, here's the Dockerfile from https://github.com/loomio/mailin-docker

FROM node:10.15.1
WORKDIR /app
EXPOSE 25
RUN apt-get update -qq
RUN apt-get install -y build-essential spamassassin spamc
RUN npm install -g mailin
CMD mailin --webhook $WEBHOOK_URL

EDIT: This looks like a bug as describe here: https://askubuntu.com/questions/422264/how-to-debug-dpkg-configure-error-in-subprocess-post-installation#422697 but I'm not sure how to apply it to the Dockerfile