abraunegg / onedrive

OneDrive Client for Linux
https://abraunegg.github.io
GNU General Public License v3.0
9.99k stars 859 forks source link

ARMHF: Building in a docker-compose file straight from the repo does not work #965

Closed breakingflower closed 4 years ago

breakingflower commented 4 years ago

Bug Report Details

Describe the bug

Build fails when building docker straight from repository.

While building the docker for an ARMHF device (Raspberry pi 4) straight from the repository as follows:

  onedrive:
    image: local-onedrive
    build: 
      context: 'https://github.com/abraunegg/onedrive.git'
      dockerfile: contrib/docker/Dockerfile-rpi # dockerfile relative to repo root
    restart: unless-stopped
    environment:
      - ONEDRIVE_UID=${PUID}
      - ONEDRIVE_GID=${PGID}
    volumes: 
      - ${CONFIG_DIR}/onedrive:/onedrive/conf
      - ${ONEDRIVE_DIR}:/onedrive/data

I get the following error:

Building onedrive
Step 1/10 : FROM debian:stretch
 ---> 6e658fcd1761
Step 2/10 : RUN apt update &&     apt install -y build-essential curl libcurl4-openssl-dev libsqlite3-dev pkg-config wget git
 ---> Using cache
 ---> 01faed3da36c
Step 3/10 : RUN wget https://github.com/ldc-developers/ldc/releases/download/v1.16.0/ldc2-1.16.0-linux-armhf.tar.xz &&     tar -xvf ldc2-1.16.0-linux-armhf.tar.xz
 ---> Using cache
 ---> a1586dd70e21
Step 4/10 : COPY . /usr/src/onedrive
 ---> 9b139994ef81
Step 5/10 : RUN cd /usr/src/onedrive/ &&     ./configure DC=/ldc2-1.16.0-linux-armhf/bin/ldmd2 &&     make clean &&     make &&     make install
 ---> Running in 88b76309111c
checking for a BSD-compatible install... /usr/bin/install -c
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for dmd... /ldc2-1.16.0-linux-armhf/bin/ldmd2
checking version of D compiler... 1.16.0
checking for curl... yes
checking for sqlite... yes
Package systemd was not found in the pkg-config search path.
Perhaps you should add the directory containing `systemd.pc'
to the PKG_CONFIG_PATH environment variable
No package 'systemd' found
Package systemd was not found in the pkg-config search path.
Perhaps you should add the directory containing `systemd.pc'
to the PKG_CONFIG_PATH environment variable
No package 'systemd' found
configure: creating ./config.status
config.status: creating Makefile
config.status: creating contrib/pacman/PKGBUILD
config.status: creating contrib/spec/onedrive.spec
config.status: creating onedrive.1
config.status: creating contrib/systemd/onedrive.service
config.status: creating contrib/systemd/onedrive@.service
rm -f onedrive onedrive.o version
rm -rf autom4te.cache
rm -f config.log config.status
if [ -f .git/HEAD ] ; then \
        git describe --tags > version ; \
else \
        echo v2.4.3-dev > version ; \
fi
fatal: No names found, cannot describe anything.
Makefile:99: recipe for target 'onedrive' failed
make: *** [onedrive] Error 128
ERROR: Service 'onedrive' failed to build: The command '/bin/sh -c cd /usr/src/onedrive/ &&     ./configure DC=/ldc2-1.16.0-linux-armhf/bin/ldmd2 &&     make clean &&     make &&     make install' returned a non-zero code: 2

It first fails on not being able to find systemd. Next, it fails on makefile line 99 trying to get tags from the repo. After some googling I have found that this docker build context is a shallow clone which is not allowed.

Machine Info

OS: Linux naspi 4.19.102-v7l+ #1295 SMP Thu Feb 6 15:49:36 GMT 2020 armv7l GNU/Linux Headless OneDrive Account type: not important DMD / LDC: I use the raspberry pi dockerfile. This uses LDC. Application configuration: not important Curl version: not important

Can someone please aid me in solving this issue. It would be really nice to build for armhf devices straight from the github repo using the file provided in the contrib folder.

abraunegg commented 4 years ago

@pauliacomi Can you provide some assistance here as the author of this file

fersalme commented 4 years ago

Hi, I builded onedrive docker imagen from this repository for Raspbery pi 3B+ and I got the same error two days ago. The R-Pi didn't enough swap memory allocate for the process. You can look in the file /etc/dphys-swapfile the CONF_SWAPSIZE and modifique to CONF_SWAPSIZE=2024. Reebot and try it again.

pauliacomi commented 4 years ago

@fl0r1s, @fersalme is correct, it is related to the swap memory of the Pi. The lack of systemd is not important on the build image. I personally used the following to make a separate 1.5 GB swapfile:

cd /var 
sudo fallocate -l 1.5G swapfile
sudo chmod 600 swapfile
sudo mkswap swapfile
sudo swapon swapfile
# make swap permanent
sudo nano /etc/fstab
# add "/swapfile swap swap defaults 0 0" at the end of file
# check it has been assigned
swapon -s
free -h

@fersalme's suggestion seems simpler, I would first try that as I expect it does the same thing. Please let me know if it works.

abraunegg commented 4 years ago

@pauliacomi , @fersalme Many thanks for this. Sounds like this should be added to a wiki entry or at least to the docker.md file.

pauliacomi commented 4 years ago

@abraunegg I think in the install configuration would be ideal, because I think it is needed on non-Docker installs. Potentially it can be also mentioned in Docker instructions.

abraunegg commented 4 years ago

@pauliacomi The install doc already has this detailed: https://github.com/abraunegg/onedrive/blob/master/docs/INSTALL.md#build-requirements

  • Build environment must have at least 1GB of memory & 1GB swap space
  • libcurl
  • SQLite 3 >= 3.7.15
  • Digital Mars D Compiler (DMD)

But nothing calls this out that it is needed for Docker builds ..

pauliacomi commented 4 years ago

@abraunegg Ah I missed that there.

Though for Docker builds it is expected that you can build onedrive non-dockerized first. Maybe a "Building and running on a Raspberry Pi" section added in https://github.com/abraunegg/onedrive/blob/master/docs/Docker.md ?

Alternatively it would be nice if an arm image could be maintained in the driveone/onedrive channel.

abraunegg commented 4 years ago

@pauliacomi

Alternatively it would be nice if an arm image could be maintained in the driveone/onedrive channel

I tried to do that - using the ARM Docker file as an automated build fails to work.

pauliacomi commented 4 years ago

@abraunegg Unfortunate... I saw you are using Travis.ci for ARM testing. You could potentially auto-push an image to DockerHub as a deploy stage?

abraunegg commented 4 years ago

@pauliacomi Yep - however that builds / tests under ARM - using qemu, to ensure that at least the compiler / code works / executes on ARMHF / ARM64.

Not doing at present any docker builds that way. If you want to maybe try and get this working/ develop a PR that expands the existing Travis CI process to do this that would be great.

pauliacomi commented 4 years ago

@abraunegg I'll consider giving it a try, I need to get up to speed with the pipeline.

breakingflower commented 4 years ago

I have tried both @pauliacomi and @fersalme's solutions but neither work.

I edited the /etc/dphys-swapfile to have CONF_MAXSWAP=4096 (the size of the rpi ram).

Next, I removed the swap partition and reinstalled it as described in the docs:

sudo dphys-swapfile uninstall
sudo dphys-swapfile setup # this generates a swapfile of 4096 
sudo dphys-swapfile swapon # enable swapfile
sudo reboot

Finally, I restarted my build docker-compose build --no-cache onedrive. Using this strategy the same errors as mentioned in the initial post occur.

However, I also tried building it locally, i.e. docker build . -t local-onedrive -f contrib/docker/Dockerfile-rpi and building succeeds.

As mentioned before, it fails on makefile line 99 trying to get tags from the repo.

if [ -f .git/HEAD ] ; then \
        git describe --tags > version ; \
else \
        echo $(version) > version ; \
fi

Are these checks on the tags necessary? Perhaps it can be updated using this stackoverflow solution, ergo git describe --always

On a different topic ( can also make this into a new issue if you would prefer this ), the first run of the docker should also be updated in docker.md to avoid user conflicts:

docker run -it --restart unless-stopped --name onedrive -v onedrive_conf:/onedrive/conf -v "${onedriveDir}:/onedrive/data" -e "ONEDRIVE_UID:PID" -e "ONEDRIVE_GID:GID" driveone/onedrive
abraunegg commented 4 years ago

@fl0r1s Thanks for the update.

Please submit new issues and PR's for any document changes that you feel could improve the existing documentation.

breakingflower commented 4 years ago

@abraunegg
Submitted a PR containing some changes in the Docker.md file.

Please note that the provided idea by @pauliacomi and @fersalme do not yield a solution on my rpi4.

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.