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

Added Docker support for server only mode #673

Merged
merged 6 commits into from
Jan 31, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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
72 changes: 72 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Various Node ignoramuses.

logs
*.log
npm-debug.log*
pids
*.pid
*.seed
lib-cov
coverage
.grunt
.lock-wscript
build/Release
node_modules
jspm_modules
.npm
.node_repl_history

# Various Windows ignoramuses.
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msm
*.msp
*.lnk

# Various OSX ignoramuses.
.DS_Store
.AppleDouble
.LSOverride
Icon
._*
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Various Linux ignoramuses.

.fuse_hidden*
.directory
.Trash-*

# Various Magic Mirror ignoramuses and anti-ignoramuses.

# Don't ignore the node_helper core module.
!/modules/node_helper
!/modules/node_helper/**

# Ignore all modules except the default modules.
/modules/**
!/modules/default/**

# Ignore changes to the custom css files.
/css/custom.css

# Ignore unnecessary files for docker
CHANGELOG.md
LICENSE.md
README.md
Gruntfile.js
.*
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Temporary Items

# Various Magic Mirror ignoramuses and anti-ignoramuses.

# Don't ignore the node_helper nore module.
# Don't ignore the node_helper core module.
!/modules/node_helper
!/modules/node_helper/**

Expand Down
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:latest

WORKDIR /opt/magic_mirror
COPY . .
COPY /modules unmount_modules
COPY /config unmount_config

ENV NODE_ENV production
ENV MM_PORT 8080

RUN npm install
RUN ["chmod", "+x", "docker-entrypoint.sh"]

EXPOSE $MM_PORT
ENTRYPOINT ["/opt/magic_mirror/docker-entrypoint.sh"]
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,41 @@ curl -sL https://raw.githubusercontent.com/MichMich/MagicMirror/master/installer
**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
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.


In some cases, you want to start the application without an actual app window. In this case, execute the following command from the MagicMirror folder: `node serveronly`. This will start the server, after which you can open the application in your browser of choice.
#### Docker

MagicMirror² in server only mode can be deployed using [Docker](https://docker.com). After a successful [Docker installation](https://docs.docker.com/engine/installation/) you just need to execute the following command in the shell:

```bash
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 \
MichMich/MagicMirror
```

| **Volumes** | **Description** |
| --- | --- |
| `/opt/magic_mirror/config` | Mount this volume to insert your own config into the docker container. |
| `/opt/magic_mirror/modules` | Mount this volume to add your own custom modules into the docker container. |

You may need to add your Docker Host IP to your `ipWhitelist` option. If you have some issues setting up this configuration, check [this forum post](https://forum.magicmirror.builders/topic/1326/ipwhitelist-howto).

```javascript
var config = {
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:172.17.0.1"]
};
```

#### 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
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
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
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
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
Contributor

Choose a reason for hiding this comment

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

Yes.

3. Enter the repository: `cd ~/MagicMirror`
4. Install and run the app: `node serveronly`

### Raspberry Configuration & Auto Start.

Expand Down
11 changes: 11 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

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

if [ ! -f /opt/magic_mirror/config ]; then
cp -R /opt/magic_mirror/unmount_config/. /opt/magic_mirror/config
fi

node serveronly
2 changes: 1 addition & 1 deletion js/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

var defaults = {
port: 8080,
port: process.env.MM_PORT || 8080,
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 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
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
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
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

kioskmode: false,
electronOptions: {},
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
Expand Down