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

Fix image build & provide multi-arch image #25

Merged
merged 15 commits into from
Aug 17, 2019
File renamed without changes.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config
modules
27 changes: 21 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 7 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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. <br><br> **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
Expand Down
9 changes: 5 additions & 4 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
97 changes: 97 additions & 0 deletions mm-docker-config.js
Original file line number Diff line number Diff line change
@@ -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; }
21 changes: 0 additions & 21 deletions raspberry/Dockerfile

This file was deleted.

14 changes: 14 additions & 0 deletions test-build.sh
Original file line number Diff line number Diff line change
@@ -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