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

Add the ability to use the docker image with a raspberry pi #846

Merged
merged 3 commits into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [2.1.2] - Unreleased

### Changed
- Change Docker base image (Debian + Node) to an arm based distro (AlpineARM + Node) ([#846](https://github.com/MichMich/MagicMirror/pull/846))
- Fix the dockerfile to have it running from the first time.

### Added
Expand Down
31 changes: 18 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
FROM node:latest
FROM izone/arm:node

# Set env variables
ENV NODE_ENV production
ENV MM_PORT 8080

WORKDIR /opt/magic_mirror

COPY . .
COPY /modules unmount_modules
COPY /config unmount_config
# Cache node_modules
COPY package.json /opt/magic_mirror
RUN npm install

# Copy all needed files
COPY . /opt/magic_mirror

# Save/Cache config and modules folder for docker-entrypoint
COPY /modules /opt/magic_mirror/unmount_modules
COPY /config /opt/magic_mirror/unmount_config

RUN apt-get update \
&& apt-get -qy install tofrodos dos2unix \
&& chmod -R 777 vendor \
&& npm install \
&& cd vendor \
&& npm install \
&& cd .. \
&& dos2unix docker-entrypoint.sh \
&& chmod +x docker-entrypoint.sh
# Convert docker-entrypoint.sh to unix format and grant execution privileges
RUN apk update \
&& apk add dos2unix --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted \
&& dos2unix docker-entrypoint.sh \
&& chmod +x docker-entrypoint.sh

EXPOSE $MM_PORT
ENTRYPOINT ["/opt/magic_mirror/docker-entrypoint.sh"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ docker run -d \
--volume ~/magic_mirror/config:/opt/magic_mirror/config \
--volume ~/magic_mirror/modules:/opt/magic_mirror/modules \
--name magic_mirror \
MichMich/MagicMirror
michmich/magicmirror
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MichMich Also if you successfully created the automated build, we need to check, if the naming is still correct. (docker_id/repo_name)

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi. I've tried to build a docker image based on this Dockerfile and it fails:

Sending build context to Docker daemon 7.095 MB
Step 1/12 : FROM izone/arm:node
node: Pulling from izone/arm
c5223e92d61a: Pull complete
1360befcec1b: Pull complete
Digest: sha256:2d7ef24f6bdf6c7e462587c2054755f383f8f35ea73bf3aba74f68859b7610b2
Status: Downloaded newer image for izone/arm:node
 ---> 4a6b73a00ecb
Step 2/12 : ENV NODE_ENV production
 ---> Running in f729f4b4891d
 ---> f2f5459d46a2
Removing intermediate container f729f4b4891d
Step 3/12 : ENV MM_PORT 8080
 ---> Running in 394f3d8d009f
 ---> 94571211dd56
Removing intermediate container 394f3d8d009f
Step 4/12 : WORKDIR /opt/magic_mirror
 ---> 54fba0cc5e8c
Removing intermediate container 50ff50c69f23
Step 5/12 : COPY package.json /opt/magic_mirror
 ---> 87954b5aa71b
Removing intermediate container 64a25a5d5b66
Step 6/12 : RUN npm install
 ---> Running in 009897841bcf
standard_init_linux.go:178: exec user process caused "exec format error"
The command '/bin/sh -c npm install' returned a non-zero code: 1

My setup is: Windows 7 64bit, docker Server Version: 17.04.0-ce

While current master's Dockerfile ( 25b5daf ) builds fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mh, looks like an error caused by windows because it works on macOS. It could be possible, that dos2unix isn't converting the file correctly. But I never worked with dos2unix before. I just copied this part from PR #743

Copy link
Contributor Author

@bastilimbach bastilimbach Apr 16, 2017

Choose a reason for hiding this comment

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

@z0diak could you check if the dockerfile from this commit (#825) works? I don't have a windows machine to test this.

Copy link
Contributor

Choose a reason for hiding this comment

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

@bastilimbach , yes, it builds successfully. I think dos2unix has nothing to do with it since it fails on RUN npm install command, before first dos2unix call. I've googled this errors message and it shows A LOT issues like this for different containers that uses ARM. Some issues for Mac (moby/moby#23865), some for linux and windows

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That unfortunate. I think it fails on some mac and windows machines because the arm image doesn't work with the kernel of the "root" os.
We could get around this issue by providing a "recommended server os" section or two dockfile versions. One which uses an arm base image and one which uses normal ubuntu or some sort of x86 os. @MichMich what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could also use the docker tag feature. So michmich/magicmirror:latest uses an ubuntu image whereas michmich/magicmirror:arm uses an arm type os.

```

| **Volumes** | **Description** |
Expand Down
4 changes: 2 additions & 2 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#!/bin/sh

if [ ! -f /opt/magic_mirror/modules ]; then
cp -R /opt/magic_mirror/unmount_modules/. /opt/magic_mirror/modules
cp -Rn /opt/magic_mirror/unmount_modules/. /opt/magic_mirror/modules
fi

if [ ! -f /opt/magic_mirror/config ]; then
Expand Down