Skip to content

Added Docker support for server only mode - #673

Merged
MichMich merged 6 commits into
MagicMirrorOrg:developfrom
bastilimbach:feature/docker
Jan 31, 2017
Merged

MichMich merged 6 commits into
MagicMirrorOrg:developfrom
bastilimbach:feature/docker

Conversation

@bastilimbach

@bastilimbach bastilimbach commented Jan 31, 2017 •

Copy link
Copy Markdown
Contributor

I added a Dockerfile and some additional docker related files to support the deployment of the server only mode using Docker.

@MichMich to make the shell command work you need to create an account at Docker Hub and link this repository to it. So every time the Github Repo gets updated, the Docker Image will be rebuild and updated automatically.

Is it correct to add my changes under the "## [2.1.0] - 2016-12-31" section of the changelog?

  • Add the change to CHANGELOG.md

Comment thread README.md Outdated
#### Manual

1. Download and install the latest Node.js version.
2. Clone the repository and check out the beta branch: `git clone https://github.com/MichMich/MagicMirror`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should set master branch here not beta.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What do you mean? Where did I use the "beta" branch?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, beta branch isn't use anymore. When you do it a checkout from url is used master branch. Just change the beta by master.

This is change done few days ago
a591cf1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh now I see what you mean. Sorry. I just copied it from line 40. Should I change it there too?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes.

Comment thread README.md Outdated
**Note:** if you want to debug on Raspberry Pi you can use `npm start dev` which will start the MagicMirror app with Dev Tools enabled.

### Server Only
In some cases, you want to start the application without an actual app window. In this case, you can start MagicMirror² in server only mode. This will start the server, after which you can open the application in your browser of choice.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No remove reference to command node serveronly some users can be not understand how run the mode server only.

@roramirez roramirez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like it this change. After this can be take the next step mentioned on forum by @morozgrafix

https://forum.magicmirror.builders/post/12602

There some little things are need to change.

@MichMich

Copy link
Copy Markdown
Collaborator

@bastilimbach Please add your changes to the [2.1.1] - Unreleased section of the CHANGELOG. Aso, the change doesn't seem to pass the travis test. Please run grunt to check what's wrong.

Thanks for your contribution!

Comment thread js/defaults.js Outdated

var defaults = {
port: 8080,
port: process.env.MM_PORT || 8080,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@MichMich I did run grunt before and couldn't figure out what the problem was. jsLint says there are irregular whitespaces but there aren't any. Or am I completely wrong here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

After MM_PORT there a stranger space. Irregular whitespace. In character 30. Add a normal space.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Strange. But it worked. Thanks 👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Various whitespace characters can be inputted by programmers by mistake for example from copying or keyboard shortcuts. Pressing Alt + Space on OS X adds in a non breaking space character for example.
http://eslint.org/docs/rules/no-irregular-whitespace

@MichMich
MichMich merged commit 049d249 into MagicMirrorOrg:develop Jan 31, 2017
@MichMich

Copy link
Copy Markdown
Collaborator

Nice work! Thanks!

@morozgrafix

Copy link
Copy Markdown
Contributor

@bastilimbach Looks like this change is causing black screen on load when starting MM with npm start or node serveronly and following error in the console log of chrome/electron.

Uncaught ReferenceError: process is not defined
    at defaults.js:11
(anonymous) @ defaults.js:11

I believe that culprit is 354b745#diff-75953debd6cf3faf33d4ff10e8353645R11

More details https://forum.magicmirror.builders/post/13221

roramirez added a commit to roramirez/MagicMirror that referenced this pull request Feb 1, 2017
roramirez added a commit to roramirez/MagicMirror that referenced this pull request Feb 1, 2017
MichMich added a commit that referenced this pull request Feb 1, 2017
@fewi

fewi commented Mar 2, 2017

Copy link
Copy Markdown
Contributor

@MichMich to make the shell command work you need to create an account at Docker Hub and link this repository to it. So every time the Github Repo gets updated, the Docker Image will be rebuild and updated automatically.

Any progress on this? Would be nice to get updated Docker images at Docker Hub

@bastilimbach

Copy link
Copy Markdown
Contributor Author

@fewi Version 2.1.1 isn't released yet. Look at the Changelog. I think with the release of 2.1.1, @MichMich will put the image onto Docker Hub.

@MichMich

MichMich commented Mar 2, 2017

Copy link
Copy Markdown
Collaborator

@fewi For now you can just use the develop branch.

@bastilimbach

Copy link
Copy Markdown
Contributor Author

@fewi @MichMich Yeah, you can checkout the develop branch and build the image yourself by running:

docker build -t magic_mirror .

After building the image, run a container with this image by executing:

docker run  -d \
            --publish 80:8080 \
            --restart always \
            --volume ~/magic_mirror/config:/opt/magic_mirror/config \
            --volume ~/magic_mirror/modules:/opt/magic_mirror/modules \
            --name magic_mirror \
            magic_mirror

You might want to change the volume paths.

@fewi

fewi commented Mar 3, 2017

Copy link
Copy Markdown
Contributor

Yesterday I was trying to build & run it on my windows machine. But it did not work. I made a PR to fix this #743

@AnyKey8472

Copy link
Copy Markdown

Hello everybody,
I tried to get this docker image to run on my 6.1.1 Synology DS, but strugled with the installation steps. After downloading it via synology gui and (what I first thought was the installation) unpacking it, I don't know how to run the above mentioned code.
I'm new to docker in generell and a little bit overwhelmed, is there a readme, or tutorial, how to setup your docker container on a synology system?
Thanks
Andre

khassel pushed a commit that referenced this pull request Jul 7, 2026
I took a look at the last remaining FIXME comment in the code - the one
in `js/app.js` pointing to PR #673. It's from 2017 and was already
flagged as a hotfix back then.

The problem: `MM_PORT` got written into a global `global.mmPort` that
was then read inconsistently across the code - sometimes via the global,
sometimes straight from `process.env`, plus separate logic in
`defaults.js`. Three ways to get the same port.

I pulled this into a single `getServerPort()` helper (`MM_PORT` ->
`config.port` -> `8080`) and switched `app.js`, `defaults.js`,
`server.js`, `electron.js` and both serveronly files over to it. The
global is gone now.

Basically the behavior should be unchanged.
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.

6 participants