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

Use smaller base image #46

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.github
config
modules
build.sh
test-build.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

what about the .git directly, should it also be ignored?

Copy link
Author

Choose a reason for hiding this comment

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

Please see my comment #46 (comment)

13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ sudo: required
services:
- docker
language: bash

env:
- MM_VERSION=2.12.0
PLATFORM=12-alpine
- MM_VERSION=2.12.0
PLATFORM=12-buster
- MM_VERSION=2.12.0
PLATFORM=14-alpine
- MM_VERSION=2.12.0
PLATFORM=14-buster

before_script:
# Upgrade Docker and enable experimental mode
- curl -fsSL https://get.docker.com | sh
Expand All @@ -24,6 +35,6 @@ script:
dopush="--push"
fi
# Build the latest stable MagicMirror release
- ./build.sh ${dopush}
- ./build.sh $MM_VERSION $PLATFORM ${dopush}
after_script:
- docker logout
58 changes: 58 additions & 0 deletions 2.12.0/12-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM node:12-alpine AS BUILD_IMAGE

ARG branch=master

ENV NODE_ENV production
WORKDIR /opt/magic_mirror

# get magic mirror
RUN apk update && apk add --no-cache git \
&& git clone --depth 1 -c advice.detachedHead=false -b ${branch} https://github.com/MichMich/MagicMirror.git .

# save default modules and configuration and install dependencies
RUN set -o pipefail \
&& mkdir dist \
&& cp -R config /opt/magic_mirror/dist/default_config \
&& cp -R modules /opt/magic_mirror/dist/default_modules \
&& npm set unsafe-perm true \
&& npm ci \
# removes required depdencies and should not be used
# && npm prune --production --json \
# prune unnecessary files from ./node_modules, such as markdown, typescript source files, and so on. https://github.com/tj/node-prune
&& wget -q https://install.goreleaser.com/github.com/tj/node-prune.sh | sh \
# it is intentional that modules are not copied to dist folder. Please keep alphabetically sorted
&& cp -R \
.git \
config \
css \
fonts \
index.html \
js \
node_modules \
package.json \
package-lock.json \
serveronly \
translations \
vendor /opt/magic_mirror/dist


FROM node:12-alpine

WORKDIR /opt/magic_mirror

RUN set -x \
&& apk update && apk add --no-cache git \
&& apk add --no-cache --update libintl \
&& apk add --no-cache --virtual build_deps gettext \
&& cp /usr/bin/envsubst /usr/local/bin/envsubst \
&& apk del build_deps \
&& mv /usr/local/bin/envsubst /usr/bin/envsubst

COPY --from=BUILD_IMAGE /opt/magic_mirror/dist/ .

EXPOSE 8080

COPY mm-docker-config.js docker-entrypoint.sh ./

ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["node", "serveronly"]
16 changes: 16 additions & 0 deletions 2.12.0/12-alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
set -e

if [ ! "$(ls -A /opt/magic_mirror/modules)" ]; then
cp -R /opt/magic_mirror/default_modules/. /opt/magic_mirror/modules
fi

if [ ! "$(ls -A /opt/magic_mirror/config)" ]; then
cp /opt/magic_mirror/mm-docker-config.js /opt/magic_mirror/config/config.js
fi

if [ -f "/opt/magic_mirror/config/config.js.template" ]; then
envsubst < /opt/magic_mirror/config/config.js.template > /opt/magic_mirror/config/config.js
fi

exec "$@"
97 changes: 97 additions & 0 deletions 2.12.0/12-alpine/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: "0.0.0.0", // 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; }
File renamed without changes.
16 changes: 16 additions & 0 deletions 2.12.0/12-buster/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
set -e

if [ ! "$(ls -A /opt/magic_mirror/modules)" ]; then
cp -R /opt/magic_mirror/default_modules/. /opt/magic_mirror/modules
fi

if [ ! "$(ls -A /opt/magic_mirror/config)" ]; then
cp /opt/magic_mirror/mm-docker-config.js /opt/magic_mirror/config/config.js
fi

if [ -f "/opt/magic_mirror/config/config.js.template" ]; then
envsubst < /opt/magic_mirror/config/config.js.template > /opt/magic_mirror/config/config.js
fi

exec "$@"
97 changes: 97 additions & 0 deletions 2.12.0/12-buster/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: "0.0.0.0", // 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; }
58 changes: 58 additions & 0 deletions 2.12.0/14-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM node:14-alpine AS BUILD_IMAGE

ARG branch=master

ENV NODE_ENV production
WORKDIR /opt/magic_mirror

# get magic mirror
RUN apk update && apk add --no-cache git \
&& git clone --depth 1 -c advice.detachedHead=false -b ${branch} https://github.com/MichMich/MagicMirror.git .

# save default modules and configuration and install dependencies
RUN set -o pipefail \
&& mkdir dist \
&& cp -R config /opt/magic_mirror/dist/default_config \
&& cp -R modules /opt/magic_mirror/dist/default_modules \
&& npm set unsafe-perm true \
&& npm ci \
# removes required depdencies and should not be used
# && npm prune --production --json \
# prune unnecessary files from ./node_modules, such as markdown, typescript source files, and so on. https://github.com/tj/node-prune
&& wget -q https://install.goreleaser.com/github.com/tj/node-prune.sh | sh \
# it is intentional that modules are not copied to dist folder. Please keep alphabetically sorted
&& cp -R \
.git \
config \
css \
fonts \
index.html \
js \
node_modules \
package.json \
package-lock.json \
serveronly \
translations \
vendor /opt/magic_mirror/dist


FROM node:12-alpine

WORKDIR /opt/magic_mirror

RUN set -x \
&& apk update && apk add --no-cache git \
&& apk add --no-cache --update libintl \
&& apk add --no-cache --virtual build_deps gettext \
&& cp /usr/bin/envsubst /usr/local/bin/envsubst \
&& apk del build_deps \
&& mv /usr/local/bin/envsubst /usr/bin/envsubst

COPY --from=BUILD_IMAGE /opt/magic_mirror/dist/ .

EXPOSE 8080

COPY mm-docker-config.js docker-entrypoint.sh ./

ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["node", "serveronly"]
16 changes: 16 additions & 0 deletions 2.12.0/14-alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
set -e

if [ ! "$(ls -A /opt/magic_mirror/modules)" ]; then
cp -R /opt/magic_mirror/default_modules/. /opt/magic_mirror/modules
fi

if [ ! "$(ls -A /opt/magic_mirror/config)" ]; then
cp /opt/magic_mirror/mm-docker-config.js /opt/magic_mirror/config/config.js
fi

if [ -f "/opt/magic_mirror/config/config.js.template" ]; then
envsubst < /opt/magic_mirror/config/config.js.template > /opt/magic_mirror/config/config.js
fi

exec "$@"
Loading