diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md
similarity index 100%
rename from CODE_OF_CONDUCT.md
rename to .github/CODE_OF_CONDUCT.md
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c764016
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+config
+modules
diff --git a/.travis.yml b/.travis.yml
index cce2bab..edfa2eb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,16 +1,31 @@
-# https://blog.hypriot.com/post/setup-simple-ci-pipeline-for-arm-images/
sudo: required
services:
- docker
language: bash
+addons:
+ apt:
+ packages:
+ - docker-ce
+before_script:
+ - echo '{"experimental":true}' | sudo tee /etc/docker/daemon.json
+ - sudo mkdir $HOME/.docker
+ - sudo touch $HOME/.docker/config.json
+ - echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json
+ - sudo service docker restart
+ - docker info
+ - docker version
script:
- - docker build -t $DOCKER_USER/docker-magicmirror:latest .
+ - docker build -t $DOCKER_USER/docker-magicmirror:amd64 .
- docker run --rm --privileged multiarch/qemu-user-static:register --reset
- - docker build -t $DOCKER_USER/docker-magicmirror:raspberry -f ./raspberry/Dockerfile .
+ - docker build -t $DOCKER_USER/docker-magicmirror:arm .
after_success:
- >
if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
- docker login -u="$DOCKER_USER" -p="$DOCKER_PASS"
- docker push $DOCKER_USER/docker-magicmirror:raspberry
- docker push $DOCKER_USER/docker-magicmirror:latest
+ echo "$DOCKER_PASS" | docker login -u $DOCKER_USER --password-stdin
+ docker push $DOCKER_USER/docker-magicmirror:amd64
+ docker push $DOCKER_USER/docker-magicmirror:arm
+ docker manifest create $DOCKER_USER/docker-magicmirror:latest $DOCKER_USER/docker-magicmirror:arm $DOCKER_USER/docker-magicmirror:amd64
+ docker manifest annotate --arch arm $DOCKER_USER/docker-magicmirror $DOCKER_USER/docker-magicmirror:arm
+ docker manifest inspect $DOCKER_USER/docker-magicmirror
+ docker manifest push bastilimbach/docker-magicmirror
fi
diff --git a/Dockerfile b/Dockerfile
index 2d2d0e4..76c07b3 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,21 +1,18 @@
-FROM node:latest
+FROM node:12-stretch
-ENV NODE_ENV production
+RUN apt-get update
+ENV NODE_ENV production
WORKDIR /opt/magic_mirror
RUN git clone --depth 1 -b master https://github.com/MichMich/MagicMirror.git .
-
RUN cp -R modules /opt/default_modules
RUN cp -R config /opt/default_config
RUN npm install --unsafe-perm --silent
-COPY docker-entrypoint.sh /opt
-RUN apt-get update \
- && apt-get -qy install dos2unix \
- && dos2unix /opt/docker-entrypoint.sh \
- && chmod +x /opt/docker-entrypoint.sh
+COPY mm-docker-config.js docker-entrypoint.sh ./
+RUN chmod +x ./docker-entrypoint.sh
EXPOSE 8080
-CMD ["node serveronly"]
-ENTRYPOINT ["/opt/docker-entrypoint.sh"]
+ENTRYPOINT ["./docker-entrypoint.sh"]
+CMD ["node", "serveronly"]
diff --git a/LICENSE b/LICENSE
index 4d58d44..2bf4b6f 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2017 Sebastian Limbach
+Copyright (c) 2019 Sebastian Limbach
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 00d1a93..3a5e01f 100644
--- a/README.md
+++ b/README.md
@@ -4,13 +4,13 @@
[![DockerHub Badge](https://dockeri.co/image/bastilimbach/docker-magicmirror)](https://hub.docker.com/r/bastilimbach/docker-magicmirror/)
-# Why Docker? [![Build Status](https://travis-ci.org/bastilimbach/docker-MagicMirror.svg?branch=master)](https://travis-ci.org/bastilimbach/docker-MagicMirror)
+# Why Docker?
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 by manually running `node serveronly` or using Docker. This will start the server, after which you can open the application in your browser of choice.
-# Supported tags and respective `Dockerfile` links
+# Supported architectures
-- `latest` - Latest MagicMirror² server ([Dockerfile](https://github.com/bastilimbach/docker-MagicMirror/blob/master/Dockerfile))
-- `raspberry` - ARM based version to work with a Raspberry Pi ([Dockerfile](https://github.com/bastilimbach/docker-MagicMirror/blob/master/raspberry/Dockerfile))
+- `amd64` - 64 Bit based architectures (e.g: macOS, Linux, etc.)
+- `arm` - Raspberry Pi and any other arm based architectures
> The respective docker images are getting updated daily by a cron job from Travis CI.
@@ -30,21 +30,21 @@ docker run -d \
# Volumes
| **Volume** | **Description** |
| --- | --- |
-| `/opt/magic_mirror/config` | Mount this folder to insert your own config into the docker container. |
-| `/opt/magic_mirror/modules` | Mount this folder to add your own custom modules into the docker container. |
+| `/opt/magic_mirror/config` | Mount this folder to insert your own config into the docker container. If the folder is empty the container will create a default configuration which can be adapted to you likings. |
+| `/opt/magic_mirror/modules` | Mount this folder to add your own custom modules into the docker container. If the folder is empty the container will copy the [default modules](https://github.com/MichMich/MagicMirror/tree/master/modules/default) from the MagicMirror² repository into the volume. |
| `/opt/magic_mirror/css/custom.css` | Mount this file to add your own custom css into the docker container.
**Important:** You need to create the file before you run the container. Otherwise Docker will create a `custom.css` folder. |
# Config
-You need to configure your MagicMirror² config to listen on any interface and allow every ip address.
+If you start the container without providing a custom configuration it will create a default config inside the `config` volume if it is empty.
+This config can then be adapted to your likings.
+If you want to build the configuration by yourself be sure to set the following configuration properties accordingly:
```javascript
var config = {
- address: "",
- port: 8080,
- ipWhitelist: []
+ address: "", // Needs to be either "", "0.0.0.0" or "::" to make MagicMirror listen on any interface.
+ port: 8080, // If you change the port, be sure to also adapt the "--publish" flag in your docker run command. e.g: --publish 80:3000
+ ipWhitelist: [] // This is required to allow all IP addresses to access MagicMirror. Can also be set to the docker subnet.
}
-
-if (typeof module !== "undefined") { module.exports = config; }
```
# Contribution
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
index a5a7bce..00c635e 100644
--- a/docker-entrypoint.sh
+++ b/docker-entrypoint.sh
@@ -1,11 +1,12 @@
#!/bin/bash
+set -e
-if [ ! -f /opt/magic_mirror/modules ]; then
+if [ ! "$(ls -A /opt/magic_mirror/modules)" ]; then
cp -Rn /opt/default_modules/. /opt/magic_mirror/modules
fi
-if [ ! -f /opt/magic_mirror/config ]; then
- cp -Rn /opt/default_config/. /opt/magic_mirror/config
+if [ ! "$(ls -A /opt/magic_mirror/config)" ]; then
+ cp /opt/magic_mirror/mm-docker-config.js /opt/magic_mirror/config/config.js
fi
-exec $1
+exec "$@"
diff --git a/mm-docker-config.js b/mm-docker-config.js
new file mode 100644
index 0000000..18f8885
--- /dev/null
+++ b/mm-docker-config.js
@@ -0,0 +1,97 @@
+/* Magic Mirror Config Sample
+ *
+ * By Michael Teeuw http://michaelteeuw.nl
+ * MIT Licensed.
+ *
+ * For more information how you can configurate this file
+ * See https://github.com/MichMich/MagicMirror#configuration
+ *
+ */
+
+var config = {
+ address: "", // Address to listen on, can be:
+ // - "localhost", "127.0.0.1", "::1" to listen on loopback interface
+ // - another specific IPv4/6 to listen on a specific interface
+ // - "", "0.0.0.0", "::" to listen on any interface
+ // Default, when address config is left out, is "localhost"
+ port: 8080,
+ ipWhitelist: [], // Set [] to allow all IP addresses
+ // or add a specific IPv4 of 192.168.1.5 :
+ // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.1.5"],
+ // or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format :
+ // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"],
+
+ language: "en",
+ timeFormat: 24,
+ units: "metric",
+
+ modules: [
+ {
+ module: "alert",
+ },
+ {
+ module: "updatenotification",
+ position: "top_bar"
+ },
+ {
+ module: "clock",
+ position: "top_left"
+ },
+ {
+ module: "calendar",
+ header: "US Holidays",
+ position: "top_left",
+ config: {
+ calendars: [
+ {
+ symbol: "calendar-check",
+ url: "webcal://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics"
+ }
+ ]
+ }
+ },
+ {
+ module: "compliments",
+ position: "lower_third"
+ },
+ {
+ module: "currentweather",
+ position: "top_right",
+ config: {
+ location: "New York",
+ locationID: "", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
+ appid: "YOUR_OPENWEATHER_API_KEY"
+ }
+ },
+ {
+ module: "weatherforecast",
+ position: "top_right",
+ header: "Weather Forecast",
+ config: {
+ location: "New York",
+ locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
+ appid: "YOUR_OPENWEATHER_API_KEY"
+ }
+ },
+ {
+ module: "newsfeed",
+ position: "bottom_bar",
+ config: {
+ feeds: [
+ {
+ title: "New York Times",
+ url: "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml"
+ }
+ ],
+ showSourceTitle: true,
+ showPublishDate: true,
+ broadcastNewsFeeds: true,
+ broadcastNewsUpdates: true
+ }
+ },
+ ]
+
+};
+
+/*************** DO NOT EDIT THE LINE BELOW ***************/
+if (typeof module !== "undefined") { module.exports = config; }
diff --git a/raspberry/Dockerfile b/raspberry/Dockerfile
deleted file mode 100644
index 5a5c748..0000000
--- a/raspberry/Dockerfile
+++ /dev/null
@@ -1,21 +0,0 @@
-FROM hypriot/rpi-node:latest
-
-ENV NODE_ENV production
-
-WORKDIR /opt/magic_mirror
-
-RUN git clone --depth 1 -b master https://github.com/MichMich/MagicMirror.git .
-
-RUN cp -R modules /opt/default_modules
-RUN cp -R config /opt/default_config
-RUN npm install --unsafe-perm --silent
-
-COPY docker-entrypoint.sh /opt
-RUN apt-get update \
- && apt-get -qy install dos2unix \
- && dos2unix /opt/docker-entrypoint.sh \
- && chmod +x /opt/docker-entrypoint.sh
-
-EXPOSE 8080
-CMD ["node serveronly"]
-ENTRYPOINT ["/opt/docker-entrypoint.sh"]
diff --git a/test-build.sh b/test-build.sh
new file mode 100755
index 0000000..a8b7b48
--- /dev/null
+++ b/test-build.sh
@@ -0,0 +1,14 @@
+rm -rf ./config
+rm -rf ./modules
+mkdir config
+mkdir modules
+
+docker rm -f magic_mirror
+docker build -t mm:latest .
+docker run -d \
+ --publish 80:8080 \
+ --restart always \
+ --volume $PWD/config:/opt/magic_mirror/config \
+ --volume $PWD/modules:/opt/magic_mirror/modules \
+ --name magic_mirror \
+ mm:latest