Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Build, Change config to be read from env variables, and pip requirements #3

Merged
merged 1 commit into from
Sep 14, 2019

Conversation

ned-kelly
Copy link
Contributor

Add support for:

  • Docker containers,
  • Mqtt base prefix,
  • Environment variables for config (rather than having to edit the code),
  • Pip requirements

Copy link
Owner

@lolouk44 lolouk44 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Just back from holidays, will have a look and test...

@lolouk44
Copy link
Owner

Hi @ned-kelly,
Finally got some time to review your PR.
Please note this is the first time I get a PR so still learning the ropes with this.
First of all, THANKS for your contribution.
I've tried to run the docker with docker-compose but get error messages:

mi-scale    | standard_init_linux.go:190: exec user process caused "no such file or directory"

Any idea where this could come from? I've tried on Ubuntu 16.04

@lolouk44 lolouk44 merged commit 6ff78c7 into lolouk44:master Sep 14, 2019
@ned-kelly
Copy link
Contributor Author

Any idea where this could come from? I've tried on Ubuntu 16.04

Hi @lolouk44

standard_init_linux.go:190 generally means the binary can't be found (inside the container) -- so chances are the CMD or ENTRYPOINT file is not where is should be in the container, OR you're trying to run a custom command that's not installed in the container...

What happens if you run:

docker run --rm -it --privileged mi-scale_mi-scale bash

Do you get the terminal, or do you see the same error?


Also in another note, I noticed you pushed the image up to your Docker Hub -- Could I suggest you add arguments to build for armv6 and armv7 so users can run your image on the raspberry/orange pi architectures also - not just a regular x86_64 pc.

Have an awesome weekend!

@lolouk44
Copy link
Owner

lolouk44 commented Sep 15, 2019 via email

@lolouk44
Copy link
Owner

Think i've just managed to add at least an armv7 to my container.
Just did a git clone on a spare Pi3 and built the docker with :armv7 tag
then pulled the armv7 do my main server and created the manifest.
Would you be able to test to see if I screwed up?

@ned-kelly
Copy link
Contributor Author

Looking at your tags on docker hub I'm pretty sure you're ok -- Users now just need to 'pull' the image, rather than build it on the device (which is a good thing since it's much quicker to just pull the pre-built image than build on the device).

image

Unfortunately I can't test ARMv7, however if you do a ARMv6 build (Pi 1, model A & B) I'll test it as I'm running it on a Pi v1 - (and change my current setup to use your image) :)

@lolouk44
Copy link
Owner

Thanks mate.
I so far haven't figured out how to build a container with a different architecture target so haven't managed to create a container with armv6 as target. (I have an old Pi1 but got some issues there)
Do you by chance have pointers to help me build a container for armv6?
Had a quick look online but see lots of different options that somewhat contradict each other...
Thanks again

@lolouk44
Copy link
Owner

Any idea why the command RUN apk update would return a non-zero code: 139?
I tried to break the first RUN statement into multiple RUN commands. I always get the same above error message while running on my Pi 1.
Wondering if this is a memory issue, hence wanting to build on my Ubuntu machine with armv6 as target.... Anyway, going to bed now. Good morning to you ;)

@ned-kelly
Copy link
Contributor Author

Hi @lolouk44 - Shouldn't be any issues manually building the container on a pi1 - HOWEVER you may find that your network adapter is too slow if you're trying to build over wifi and not with an ethernet pugged in, and that can cause all sorts of issues (including timeouts) -- That was my problem at least when trying to build it, and I couldn't be bothered running an ethernet cable to where my PI's located...

The easiest thing to do is build the image locally on your pc (but in an emulated armv6 environment) then copy the built files onto the pi ....

If you do end up building multi-arch images (like on the blog post linked) then you can just tag and push those images up to Dockerhub with a Manifest file, and you're done - You'll have multi-arch support for the miscale images :)

The other option (if you're like me and you never update your software chances are you may be running an old docker without docker buildx support), is to just copy the large files onto the device manually using Docker save, and then do your build (This is actually what I did for the version of miscale that I'm running right now on my PI)...

For example:

Host with reliable Internet

docker pull arm32v6/python:3.8-rc-alpine
docker save -o python3.arm.docker 2a5bd28ae19c
rsync -av python3.arm.docker user@pi-ip:/opt/docker/ #NB Omit the -z flag, no point compressing the file since the CPU is so slow anyway

On your pi

sudo docker load -i python3.arm.docker

vi Dockerfile

## Edit your dockerfile like so:

Replace: FROM python:3.8-rc-alpine
With: FROM 2a5bd28ae19c

Then you can just do a docker build/docker-compose up.

Last thing to note, is that Docker for the piv1 is pretty crappy in Raspbian -- You're better running Hypriotos on the earlier PI's - and putting EVERYTHING in a docker container (makes it easier to rebuild when your SD fails anyway ;) )

https://blog.hypriot.com/downloads/

@lolouk44
Copy link
Owner

Thanks for all your help mate. Think I've just done it. If you don't mind trying and confirming please.

@ned-kelly
Copy link
Contributor Author

Hi @lolouk44,

Still not quite there...

You need to include the TAGS for each arch in your docker repo --- Have a look at the tags for the different arch's on another project i've built as an example...

I have a shell script to do the work on my CI/CD server, but you can adapt it for this project also if you like...

Example: setup-multi-arch-build.sh.zip

@lolouk44
Copy link
Owner

Thanks. Will look into your links, though I thought using docker desktop buildx allowed everything to be under the same latest tag?

@lolouk44
Copy link
Owner

lolouk44 commented Oct 7, 2019

Took me a while but I think I managed to create the multi-arch tag.
Thanks ever so much for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants