MatchbookLab / local-persist

Create named local volumes that persist in the location(s) you want
MIT License
851 stars 122 forks source link

WIP: Enable ARM build #63

Closed smueller18 closed 4 years ago

smueller18 commented 5 years ago

Docker on ARM is now supported. I tested the build successfully on my RaspberryPi using the ARM binary from https://github.com/smueller18/local-persist/releases/tag/v1.3.1.

CWSpear commented 5 years ago

Yeah, I think they've had some support for a while, I just don't really have a way to test.

Looks like something's wrong with Travis... gonna make sure things are working before I merge.

But I also had a question:

When you docker pull, does it automatically know which version to get, or do we need to create a separate tag, like cwspear/local-persist:arm and cwspear/local-persist:arm-1.3.1, etc?

smueller18 commented 5 years ago

I have no experience in building ARM Docker images. I built the binaries with my local go installation.

I cannot test the Docker build at all, because I get the following error on Ubuntu 18.10 amd64, Docker version 18.06.1-ce, build e68fc7a:

~/git/github/smueller18/local-persist(master) » make docker-build
rm -Rf bin/*
./scripts/docker-build.sh
Sending build context to Docker daemon    169kB
Step 1/8 : FROM golang:1.5
1.5: Pulling from library/golang
357ea8c3d80b: Pulling fs layer
52befadefd24: Pulling fs layer
3c0732d5313c: Pulling fs layer
fee55c622298: Pulling fs layer
fee55c622298: Waiting
70ff2aeff174: Pulling fs layer
01195e06f03d: Pulling fs layer
2f0f050412f9: Pulling fs layer
70ff2aeff174: Waiting
01195e06f03d: Waiting
2f0f050412f9: Waiting
52befadefd24: Download complete
357ea8c3d80b: Download complete
3c0732d5313c: Verifying Checksum
3c0732d5313c: Download complete
01195e06f03d: Download complete
2f0f050412f9: Verifying Checksum
2f0f050412f9: Download complete
357ea8c3d80b: Pull complete
52befadefd24: Pull complete
fee55c622298: Verifying Checksum
fee55c622298: Download complete
3c0732d5313c: Pull complete
fee55c622298: Pull complete
70ff2aeff174: Verifying Checksum
70ff2aeff174: Download complete
70ff2aeff174: Pull complete
01195e06f03d: Pull complete
2f0f050412f9: Pull complete
Digest: sha256:3be07b667a868a246b9cee4ddc5ecce2ad1e211958bd6043a25fc1d19d55e6ba
Status: Downloaded newer image for golang:1.5
 ---> 99668503de15
Step 2/8 : RUN curl https://glide.sh/get | sh
 ---> Running in c991b696c1f9
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4833  100  4833    0     0   9829      0 --:--:-- --:--:-- --:--:--  9823
ARCH=amd64
OS=linux
Using curl as download tool
Getting https://glide.sh/version
TAG=v0.13.2
GLIDE_DIST=glide-v0.13.2-linux-amd64.tar.gz
Downloading https://github.com/Masterminds/glide/releases/download/v0.13.2/glide-v0.13.2-linux-amd64.tar.gz
glide version v0.13.2 installed successfully
Removing intermediate container c991b696c1f9
 ---> 9d0d615accef
Step 3/8 : WORKDIR $GOPATH/src/local-persist
 ---> Running in 18433c383ec8
Removing intermediate container 18433c383ec8
 ---> 8726bd909b12
Step 4/8 : ENV GO15VENDOREXPERIMENT 1
 ---> Running in 717ecc9c77b7
Removing intermediate container 717ecc9c77b7
 ---> a7d3a1cb1e98
Step 5/8 : COPY glide.yaml glide.lock ./
 ---> e66997e27043
Step 6/8 : RUN glide install -v
 ---> Running in 13a52bfbf883
[INFO]  Downloading dependencies. Please wait...
[INFO]  --> Fetching github.com/coreos/pkg
[INFO]  --> Fetching github.com/fatih/color
[INFO]  --> Fetching github.com/mattn/go-colorable
[INFO]  --> Fetching github.com/opencontainers/runc
[INFO]  --> Fetching github.com/Sirupsen/logrus
[INFO]  --> Fetching github.com/mattn/go-isatty
[INFO]  --> Fetching github.com/coreos/go-systemd
[INFO]  --> Fetching github.com/docker/distribution
[INFO]  --> Fetching golang.org/x/sys
[INFO]  --> Fetching github.com/Microsoft/go-winio
[INFO]  --> Fetching github.com/docker/go-plugins-helpers
[INFO]  --> Fetching github.com/docker/go-connections
[INFO]  --> Fetching golang.org/x/net
[INFO]  --> Fetching github.com/docker/go-units
[INFO]  --> Fetching github.com/docker/engine-api
[INFO]  Setting references.
[INFO]  --> Setting version for github.com/coreos/go-systemd to 64d5cd7cb947834ef93874e82745c42ad6de4d0e.
[INFO]  --> Setting version for github.com/fatih/color to dea9d3a26a087187530244679c1cfb3a42937794.
[INFO]  --> Setting version for github.com/Microsoft/go-winio to ce2922f643c8fd76b46cadc7f404a06282678b34.
[INFO]  --> Setting version for github.com/docker/engine-api to 3d1601b9d2436a70b0dfc045a23f6503d19195df.
[INFO]  --> Setting version for github.com/Sirupsen/logrus to 55eb11d21d2a31a3cc93838241d04800f52e823d.
[INFO]  --> Setting version for github.com/docker/go-plugins-helpers to 60d242cfd0fb30e5002fbf76bf6872e81e85adba.
[INFO]  --> Setting version for github.com/docker/go-connections to f512407a188ecb16f31a33dbc9c4e4814afc1b03.
[INFO]  --> Setting version for github.com/coreos/pkg to 447b7ec906e523386d9c53be15b55a8ae86ea944.
[INFO]  --> Setting version for github.com/docker/go-units to 8a7beacffa3009a9ac66bad506b18ffdd110cf97.
[INFO]  --> Setting version for github.com/mattn/go-colorable to 6e26b354bd2b0fc420cb632b0d878abccdc6544c.
[INFO]  --> Setting version for github.com/mattn/go-isatty to 66b8e73f3f5cda9f96b69efd03dd3d7fc4a5cdb8.
[INFO]  --> Setting version for github.com/opencontainers/runc to 49ed0a10e4edba88f9221ec730d668099f6d6de8.
[INFO]  --> Setting version for github.com/docker/distribution to fbe6e8d212ed880cf7f7c9f876ba9b15c8221c5f.
[INFO]  --> Setting version for golang.org/x/net to 4876518f9e71663000c348837735820161a42df7.
[INFO]  --> Setting version for golang.org/x/sys to c200b10b5d5e122be351b67af224adc6128af5bf.
[INFO]  Exporting resolved dependencies...
[INFO]  --> Exporting github.com/coreos/pkg
[INFO]  --> Exporting github.com/docker/engine-api
[INFO]  --> Exporting github.com/docker/go-connections
[INFO]  --> Exporting github.com/docker/distribution
[INFO]  --> Exporting github.com/coreos/go-systemd
[INFO]  --> Exporting github.com/docker/go-plugins-helpers
[INFO]  --> Exporting github.com/fatih/color
[INFO]  --> Exporting github.com/docker/go-units
[INFO]  --> Exporting github.com/mattn/go-isatty
[INFO]  --> Exporting github.com/mattn/go-colorable
[INFO]  --> Exporting github.com/opencontainers/runc
[INFO]  --> Exporting github.com/Microsoft/go-winio
[INFO]  --> Exporting github.com/Sirupsen/logrus
[INFO]  --> Exporting golang.org/x/sys
[INFO]  --> Exporting golang.org/x/net
[INFO]  Replacing existing vendor dependencies
[INFO]  Removing nested vendor and Godeps/_workspace directories...
[INFO]  Removing: /go/src/local-persist/vendor/github.com/docker/distribution/vendor
[INFO]  Removing: /go/src/local-persist/vendor/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/docker/docker/vendor
[INFO]  Removing: /go/src/local-persist/vendor/github.com/opencontainers/runc/Godeps/_workspace
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x71724f]

goroutine 1 [running]:
github.com/Masterminds/glide/godep/strip.stripGodepWorkspaceHandler(0xc000024600, 0x58, 0x0, 0x0, 0x939e40, 0xc0001bf4d0, 0x0, 0x0)
    /Users/mfarina/Code/go/src/github.com/Masterminds/glide/godep/strip/strip.go:62 +0x4f
path/filepath.walk(0xc0006be280, 0x4d, 0x940ea0, 0xc0006a1ba0, 0x8da518, 0x0, 0x0)
    /usr/local/Cellar/go/1.11/libexec/src/path/filepath/path.go:378 +0x21f
path/filepath.walk(0xc0006be050, 0x42, 0x940ea0, 0xc0006a1930, 0x8da518, 0x0, 0x0)
    /usr/local/Cellar/go/1.11/libexec/src/path/filepath/path.go:382 +0x2fe
path/filepath.walk(0xc000175bc0, 0x3b, 0x940ea0, 0xc0006a1520, 0x8da518, 0x0, 0x0)
    /usr/local/Cellar/go/1.11/libexec/src/path/filepath/path.go:382 +0x2fe
path/filepath.walk(0xc000175b00, 0x36, 0x940ea0, 0xc0006a1450, 0x8da518, 0x0, 0x0)
    /usr/local/Cellar/go/1.11/libexec/src/path/filepath/path.go:382 +0x2fe
path/filepath.walk(0xc0004b47e0, 0x27, 0x940ea0, 0xc00067ab60, 0x8da518, 0x0, 0x0)
    /usr/local/Cellar/go/1.11/libexec/src/path/filepath/path.go:382 +0x2fe
path/filepath.walk(0xc00063a2c0, 0x1c, 0x940ea0, 0xc00067aa90, 0x8da518, 0x0, 0x940ea0)
    /usr/local/Cellar/go/1.11/libexec/src/path/filepath/path.go:382 +0x2fe
path/filepath.Walk(0xc00063a2c0, 0x1c, 0x8da518, 0xc00067a9c0, 0x0)
    /usr/local/Cellar/go/1.11/libexec/src/path/filepath/path.go:404 +0x105
github.com/Masterminds/glide/godep/strip.GodepWorkspace(0xc00063a2c0, 0x1c, 0xc00030c7c0, 0x0)
    /Users/mfarina/Code/go/src/github.com/Masterminds/glide/godep/strip/strip.go:39 +0x117
github.com/Masterminds/glide/path.StripVendor(0x8d0061, 0x3b)
    /Users/mfarina/Code/go/src/github.com/Masterminds/glide/path/strip.go:52 +0x13a
github.com/Masterminds/glide/action.Install(0xc0001b45c0, 0x8bb401)
    /Users/mfarina/Code/go/src/github.com/Masterminds/glide/action/install.go:62 +0x351
main.commands.func12(0xc0000f09a0, 0x0, 0xc0000f09a0)
    /Users/mfarina/Code/go/src/github.com/Masterminds/glide/glide.go:510 +0x2b5
github.com/Masterminds/glide/vendor/github.com/codegangsta/cli.HandleAction(0x832ac0, 0x8da6f0, 0xc0000f09a0, 0xc00005f800, 0x0)
    /Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/codegangsta/cli/app.go:490 +0xc8
github.com/Masterminds/glide/vendor/github.com/codegangsta/cli.Command.Run(0x8b9609, 0x7, 0x8b7c0b, 0x1, 0x0, 0x0, 0x0, 0x8c539a, 0x20, 0x0, ...)
    /Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/codegangsta/cli/command.go:210 +0x990
github.com/Masterminds/glide/vendor/github.com/codegangsta/cli.(*App).Run(0xc000089040, 0xc00001c090, 0x3, 0x3, 0x0, 0x0)
    /Users/mfarina/Code/go/src/github.com/Masterminds/glide/vendor/github.com/codegangsta/cli/app.go:255 +0x687
main.main()
    /Users/mfarina/Code/go/src/github.com/Masterminds/glide/glide.go:104 +0x556
The command '/bin/sh -c glide install -v' returned a non-zero code: 2
"docker run" requires at least 1 argument.
See 'docker run --help'.

Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container
make: *** [Makefile:20: docker-build] Error 1
RobLoach commented 5 years ago

When attempting to compile on Ubuntu 18.04, I got the same error as above.

smueller18 commented 5 years ago

The docker build errors were caused by the use of the latest version of glide. I fixed the glide version to 0.12.3. That was the latest tag when local-persist was last tagged.

CWSpear commented 5 years ago

I don't really have a way to easily test this, but if you guys say it works, I can merge it. Should probably figure out what's going on with Travis...

smueller18 commented 5 years ago

In the meantime, I informed me about how multi-arch docker images can be build. A good howto is described in https://lobradov.github.io/Building-docker-multiarch-images/ . If the local persist plugin should also be available as multi arch docker image, there is a bunch of work to do. I do not use the provided docker image for plugin installation so I cannot guarantee that this will work flawless. I just can say, that the compiled binary for ARM has been running for a few months on my RaspberryPi now. Is it an option just to add the compilation of ARM versions without providing ARM docker images? If yes, all ARM versions should be build (arm32v6 and arm64v8). I could add this.

By the way, #67 will be closed when this PR gets merged.

smueller18 commented 5 years ago

@CWSpear I implemented an automated build of the multi-arch docker images based on Travis. Please fix the Travis build on this project so that this PR will be build. I tested the ci pipeline with my master branch at https://github.com/smueller18/local-persist and tagged the latest state with v1.3.2. The docker image is automatically being built after commits on master and after creating a tag. To get Travis working, DOCKER_USERNAME=cwspear and DOCKER_PASSWORD=*** must be set as build environment variables.

I tested the latest master image on my Raspberry Pi:

» uname -a
Linux pi 4.14.79-v7+ #1159 SMP Sun Nov 4 17:50:20 GMT 2018 armv7l GNU/Linux

» docker --version
Docker version 18.09.0, build 4d60db4

» docker run -d --name local-persist -v /run/docker/plugins/:/run/docker/plugins/ -v /tmp/plugin-data:/var/lib/docker/plugin-data/ -v /tmp/data:/tmp/data smueller18/docker-local-persist-volume-plugin
bba4c3bd10b1b8f7a9c150ff09ac39f20fdf79cc5fd4e6fce5212540ca42cc26

» docker volume create -d local-persist -o mountpoint=/tmp/data --name=images 
images

» docker run --rm -v images:/data alpine touch /data/lol

» docker logs local-persist
Starting...       Found 0 volumes on startup
Get Called...     Couldn't find images
Create Called...  Ensuring directory /tmp/data exists on host...
                  Created volume images with mountpoint /tmp/data
Get Called...     Found images
Get Called...     Found images
Mount Called...   Mounted images
Path Called...    Returned path /tmp/data
Get Called...     Found images
Unmount Called... Unmounted images
Path Called...    Returned path /tmp/data

» ls -lhR /tmp/data
/tmp/data:
total 0
-rw-r--r-- 1 root root 0 Jan 28 22:48 lol
smueller18 commented 5 years ago

closes #69 #67

aheil commented 4 years ago

Any possibilities, this PR will end up in the plugin? On top of this, it would be great to support aarch64 architectures to enable the plugin on 4th Gen Raspberries.

I have forked the master from @smueller18, I was able to run the Travis CI, and it seems there are various versions including aarch64/amd64 of the plug-in build in the CI pipeline.

image

What would be necessary to get arm and aarch64 support?

CWSpear commented 4 years ago

@aheil it's been a while since I looked at this, but looking over the thread, I recall I was waiting for this to be resolved when I sort of forgot about it: https://github.com/MatchbookLab/local-persist/pull/63#pullrequestreview-197322060

smueller18 commented 4 years ago

A couple of months ago, I switched my fork to Gitlab and implemented a CD pipeline, see https://gitlab.com/smueller18/local-persist/tree/enable-arm-gitlabci. There is no issue with credentials from dockerhub because I use the Gitlab Registry which creates one time tokens for each CI Job. But this project remains in expiremental state. I did not take more effort into this because I don't use this plugin on my raspberry pi anymore.