docker-openwisp icon indicating copy to clipboard operation
docker-openwisp copied to clipboard

Installation on ARM/v8 achitecture fails

Open nikolya-prodigy opened this issue 3 years ago • 7 comments

Logs:

Downloading OpenWISP images... Starting Services... /usr/local/lib/python3.9/dist-packages/paramiko/transport.py:236: CryptographyDeprecationWarning: Blowfish has been deprecated "class": algorithms.Blowfish, 11-alpine: Pulling from mdillon/postgis Digest: sha256:c9eca7d32159529fd191239d74f2d11cb5dac1342eab426b79493bf47f933c9b Status: Downloaded newer image for mdillon/postgis:11-alpine 1.8-alpine: Pulling from library/influxdb no matching manifest for linux/arm64/v8 in the manifest list entries make: *** [Makefile:79: start] Error 1 make: Leaving directory '/opt/openwisp/docker-openwisp'

nikolya-prodigy avatar May 10 '22 12:05 nikolya-prodigy

Patches are welcome!

nemesifier avatar May 10 '22 14:05 nemesifier

Seems like you are on an unsupported architecture: linux/arm64/v8, sorry but only x86 is supported right now and making sure everything works on arm is going to take some time! 😄

P.S: I doubt this will be taken up soon unless there is huge demand for it, but as Fed said, patches are welcome! 😄

atb00ker avatar May 12 '22 19:05 atb00ker

+1 for arm support. I'm running a few OpenWrt servers, some are hardware routers, some are raspberry pi's, and all are arm... Just noticing this actually. Anyways Docker is a drop in for OpenWrt applications, and then the next awesome move would be to manage the fleet on top of it.

I'm using a few of these: https://firmware-selector.openwrt.org/?version=22.03.4&target=bcm27xx%2Fbcm2711&id=rpi-4

here's the architecture: root@OpenWrt:~# uname -a Linux OpenWrt 5.10.176 #0 SMP Sun Apr 9 12:27:46 2023 aarch64 GNU/Linux

my understanding is arm64 and aarch64 should be the ~same? Any pointers on where to start? Maybe I'll try and make a pull request. This would be super useful for me.

boschb avatar Apr 27 '23 04:04 boschb

Hi @boschb ,

Any pointers on where to start?

I never got around to solving for this, but I did some PoCs. I think adding support for arm architecture would take a bit of effort but it's possible.

The place where you'll start is:

  1. Understand the directory structure of this repo
  2. In the images/ folder, start changing the base images from amd64 versions to arm64 versions. (if you are on an amd64 machine, you'll need to install a bunch of things to build for another architecture, but it's easy)
  3. When you've made the changes, try to start build using the makefile, I am sure there will be errors because the name of the libraries/dependencies can be different.
  4. I do not think many changes would be required for configuration, but if you run into a problem, try posting here: https://app.gitter.im/#/room/#openwisp_dockerize-openwisp:gitter.im for help; someone might be able to help! :smile:

Good luck.

atb00ker avatar Apr 27 '23 20:04 atb00ker

So I got pretty far actually. I tried doing this all on the aarch64/arm64 device itself (rasp pi4) running OpenWrt. Honestly didn't expect it to go as far as it did.

It got stuck on Step 38/38 apk stuff: 1.) apk packager was missing (added), and so was the repositories. Package alpine-keys is also needed to get the repositories file available. However alpine-keys is way out of date too, so we get an UNTRUSTED warning when using it. ~mitigated

2.) The APK packages have generally been very hard to work with debugging in docker-compose. I was able to try root/nonroot accounts. use USER root in Dockerfile as well. I'm able to pull packages and then I started to unwind/update the dependencies as needed. I'm having a hard time knowing here what can/should be updated for compatibility and what need be left alone for openwisp compatibility itself. I may return to this path later, but it seems non-trivial at this point without more knowledge of how this is containerized together. There are a number of transient containers appearing on docker during builds also that I also don't fully understand yet.

So I actually am going to go exploring a direct integration in OpenWrt. The client stuff is already here, maybe I can add the server config too. First I just wana see if I can even build it on arm.

reference failures

These were the original postings I made where things got stuck.

Running as non-root, fails to connect to the apk database

git@OpenWrt:~/docker-openwisp$  apk add --no-cache             tzdata~=2022a-r0             postgresql-client~=12.10-r0             supervisor~=4.2.0-r0
ERROR: Unable to lock database: Permission denied
ERROR: Failed to open apk database: Permission denied

3.) Running 'make' as root fails to find some packages.

[+] Building 2.0s (6/9)
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                       0.0s
 => => transferring dockerfile: 1.02kB                                                                                                                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                          0.0s
 => => transferring context: 2B                                                                                                                                                                                                                            0.0s
 => [internal] load metadata for docker.io/library/alpine:3.16                                                                                                                                                                                             0.8s
 => [1/5] FROM docker.io/library/alpine:3.16@sha256:c2b622f6e510a0d25bccaffa9e67b75a6860cb09b74bb58cfc36a9ef4331109f                                                                                                                                       0.0s
 => [internal] load build context                                                                                                                                                                                                                          0.8s
 => => transferring context: 13.25kB                                                                                                                                                                                                                       0.0s
 => CACHED [2/5] WORKDIR /opt/openwisp/                                                                                                                                                                                                                    0.0s
 => CANCELED [3/5] RUN apk add --no-cache --upgrade             openssl~=1.1.1t-r0             cyrus-sasl~=2.1.28-r1             cyrus-sasl-login~=2.1.28-r1 &&     apk add --no-cache             postfix~=3.7.3-r0             rsyslog~=8.2204.1-r0      0.8s
failed to solve: executor failed running [/bin/sh -c apk add --no-cache             tzdata~=2022a-r0             postgresql-client~=12.10-r0             supervisor~=4.2.0-r0 &&     rm -rf /var/cache/apk/* /tmp/*]: exit code: 1
make: *** [Makefile:46: compose-build] Error 17

If I run the command by hand:

root@OpenWrt:/srv/git/docker-openwisp#  apk add --no-cache             tzdata~=2022a-r0             postgresql-client~=12.10-r0             supervisor~=4.2.0-r0
ERROR: unable to select packages:
  postgresql-client (no such package):
    required by: world[postgresql-client~12.10-r0]
  supervisor (no such package):
    required by: world[supervisor~4.2.0-r0]
  tzdata (no such package):
    required by: world[tzdata~2022a-r0]

I haven't checked if they actually don't exist for arm or not yet, but thought I thought I'd check in with progress report thus far. Seems very close to me, but this is my first go of this build.

boschb avatar Apr 28 '23 18:04 boschb

The APK packages have generally been very hard to work with debugging in docker-compose.

Yeah, I know! :-( That's one of the reason why I decided to remove alpine for most of the images.

non-root, fails to connect to the apk database

Yep, that'll will never work, no point finding a way, out. Simply become root and continue.

failed to solve: executor failed running [/bin/sh -c apk add --no-cache tzdata~=2022a-r0 postgresql-client~=12.10-r0 supervisor~=4.2.0-r0 && rm -rf /var/cache/apk/* /tmp/*]: exit code: 1 make: *** [Makefile:46: compose-build] Error 17

Please include logs of this run, so that I might be able to advice on this. (i.e lines after this particular line)

required by: world[postgresql-client~12.10-r0]

  1. Are you on the latest version of alpine?
  2. Can you please your version of alpine and check if the package is present here: https://pkgs.alpinelinux.org/packages ?
  3. If it's not, you'll need to find the new name of the package. (usually, just google: "X package for alpine version Y; and you'll find answer easily)

Hope this helps.

atb00ker avatar May 02 '23 16:05 atb00ker

Hi!

So I got it to build. It was not as bad as it could have been, but it certainly did not need to be this troublesome. The main issue is that that RUN does not play well on apline SH (and probably ASH/BASH too). I had to convert RUN to exec CMD[] which is odd, but seems to be the only thing that works... (some prior art here

This is not the best patch I can do, but since my time (and responses here) are limited, here is the current patch that should build on alpine aarch64. I will attempt to test it and clean it up before making a pull, but welcome any early feedback. I (though probably competent enough) honestly don't play in docker world much,, but I hope to deliver something of value as a first go here.

$ cat ~/openwisp-alpine.patch
diff --git a/Makefile b/Makefile
index 92ca244..08bc90f 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@ base-build:
        docker build --tag openwisp/openwisp-base:intermedia-system \
                     --file ./images/openwisp_base/Dockerfile \
                     --target SYSTEM ./images/; \
-       docker build --tag openwisp/openwisp-base:intermedia-python \
+       docker build  --tag openwisp/openwisp-base:intermedia-python \
                     --file ./images/openwisp_base/Dockerfile \
                     --target PYTHON ./images/ \
                     $$BUILD_ARGS; \
@@ -43,7 +43,7 @@ nfs-build:
                     --file ./images/openwisp_nfs/Dockerfile ./images/

 compose-build: base-build
-       docker-compose build --parallel
+       docker-compose --verbose build

 # Test
 runtests: develop-runtests
diff --git a/images/openwisp_freeradius/Dockerfile b/images/openwisp_freeradius/Dockerfile
index f94b71a..e361d81 100644
--- a/images/openwisp_freeradius/Dockerfile
+++ b/images/openwisp_freeradius/Dockerfile
@@ -1,12 +1,8 @@
 FROM freeradius/freeradius-server:3.0.26-alpine

 # hadolint ignore=DL3018
-RUN apk add --no-cache --update tzdata~=2022f-r1 postgresql-dev~=13.8-r0 \
-                                postgresql-client~=13.8-r0 && \
-    rm -rf /var/cache/apk/* /tmp/*
-
-RUN addgroup -S freerad && \
-    adduser -S freerad -G freerad
+CMD ["/bin/sh", "-c", "apk add --no-cache --update tzdata~=2023c-r1 postgresql-dev~=13.8-r0 postgresql-client~=13.8-r0"]
+CMD ["/bin/sh", "-c", "addgroup -S freerad && adduser -S freerad -G freerad"]

 CMD ["sh", "init_command.sh"]
 EXPOSE 1812/udp 1813/udp
@@ -15,8 +11,7 @@ EXPOSE 1812/udp 1813/udp
 COPY ./common/init_command.sh \
     ./common/utils.sh ./
 COPY ./openwisp_freeradius/raddb/ /etc/raddb/
-RUN chown -R freerad:root /opt/etc/raddb/ && \
-    chown -R freerad:root /opt/var/log/
+CMD ["/bin/sh", "-c", "chown -R freerad:root /opt/etc/raddb/ && chown -R freerad:root /opt/var/log/"]

 ENV TZ=UTC \
     MODULE_NAME=freeradius \
diff --git a/images/openwisp_nfs/Dockerfile b/images/openwisp_nfs/Dockerfile
index dd16f08..45d6339 100644
--- a/images/openwisp_nfs/Dockerfile
+++ b/images/openwisp_nfs/Dockerfile
@@ -2,7 +2,7 @@ FROM alpine:3.16

 # hadolint ignore=DL3018
 RUN apk add --no-cache --update --verbose \
-            tzdata~=2022f-r1 \
+            tzdata~=2023c-r1 \
             nfs-utils~=2.6.1-r1 && \
     rm -rf /var/cache/apk/* /tmp/*

diff --git a/images/openwisp_nginx/Dockerfile b/images/openwisp_nginx/Dockerfile
index 3e3ad8e..1cbc95f 100644
--- a/images/openwisp_nginx/Dockerfile
+++ b/images/openwisp_nginx/Dockerfile
@@ -1,10 +1,6 @@
 FROM nginx:1.23.3-alpine

-RUN apk add --update --no-cache \
-            openssl~=3.0.8-r0 \
-            certbot~=1.32.0-r0 \
-            certbot-nginx~=1.32.0-r0 && \
-    rm -rf /var/cache/apk/* /tmp/*
+CMD ["/bin/sh", "-c", "apk add --update --no-cache openssl~=3.0.8-r0 certbot~=1.32.0-r0  certbot-nginx~=1.32.0-r0"]

 WORKDIR /etc/nginx/
 CMD ["sh", "init_command.sh"]
@@ -16,7 +12,7 @@ COPY ./common/services.py \
     ./openwisp_nginx/ \
     /etc/nginx/

-RUN pip install --no-cache-dir -r requirements.txt
+CMD ["/bin/sh", "-c", "python -m pip install --no-cache-dir -r requirements.txt"]

 ENV MODULE_NAME=nginx \
     PYTHONUNBUFFERED=1 \
diff --git a/images/openwisp_openvpn/Dockerfile b/images/openwisp_openvpn/Dockerfile
index 5a87d94..a4f500f 100644
--- a/images/openwisp_openvpn/Dockerfile
+++ b/images/openwisp_openvpn/Dockerfile
@@ -1,11 +1,9 @@
 # hadolint ignore=DL3007
-FROM kylemanna/openvpn:2.4
+FROM kylemanna/openvpn
+
+#USER root
+CMD ["/bin/sh/", "-c", "apk add --no-cache --upgrade tzdata~=2023c-r1 postgresql15-client~=15.2-r4 supervisor~=4.2.5-r2"]

-RUN apk add --no-cache \
-            tzdata~=2022a-r0 \
-            postgresql-client~=12.10-r0 \
-            supervisor~=4.2.0-r0 && \
-    rm -rf /var/cache/apk/* /tmp/*
 CMD ["sh", "init_command.sh"]
 EXPOSE 1194

diff --git a/images/openwisp_postfix/Dockerfile b/images/openwisp_postfix/Dockerfile
index 4c680d1..7fed0c6 100644
--- a/images/openwisp_postfix/Dockerfile
+++ b/images/openwisp_postfix/Dockerfile
@@ -1,15 +1,8 @@
-FROM alpine:3.16
+FROM alpine

 WORKDIR /opt/openwisp/
-RUN apk add --no-cache --upgrade \
-            openssl~=1.1.1t-r0 \
-            cyrus-sasl~=2.1.28-r1      \
-            cyrus-sasl-login~=2.1.28-r1 && \
-    apk add --no-cache \
-            postfix~=3.7.3-r0 \
-            rsyslog~=8.2204.1-r0        \
-            tzdata~=2022f-r1 && \
-    rm -rf /tmp/* /var/cache/apk/*
+USER root
+CMD ["/bin/sh", "-c", "apk add --no-cache --upgrade openssl~=3.1.0-r4 cyrus-sasl~=2.1.28-r4 cyrus-sasl-login~=2.1.28-r4 && apk add --no-cache --upgrade postfix~=3.8.0-r1 rsyslog~=8.2304.0-r0 tzdata~=2023c-r1 && rm -rf /tmp/* /var/cache/apk/*"]

 CMD ["sh", "init_command.sh"]
 EXPOSE 25

boschb avatar May 08 '23 03:05 boschb