diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..96567b4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.github +config +modules +build.sh +test-build.sh \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 2c6ed65..54edfa0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -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 diff --git a/2.12.0/12-alpine/Dockerfile b/2.12.0/12-alpine/Dockerfile new file mode 100644 index 0000000..6d28e82 --- /dev/null +++ b/2.12.0/12-alpine/Dockerfile @@ -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"] diff --git a/2.12.0/12-alpine/docker-entrypoint.sh b/2.12.0/12-alpine/docker-entrypoint.sh new file mode 100755 index 0000000..5f17a23 --- /dev/null +++ b/2.12.0/12-alpine/docker-entrypoint.sh @@ -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 "$@" diff --git a/2.12.0/12-alpine/mm-docker-config.js b/2.12.0/12-alpine/mm-docker-config.js new file mode 100644 index 0000000..7ae119c --- /dev/null +++ b/2.12.0/12-alpine/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: "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; } diff --git a/Dockerfile b/2.12.0/12-buster/Dockerfile similarity index 100% rename from Dockerfile rename to 2.12.0/12-buster/Dockerfile diff --git a/2.12.0/12-buster/docker-entrypoint.sh b/2.12.0/12-buster/docker-entrypoint.sh new file mode 100755 index 0000000..5f17a23 --- /dev/null +++ b/2.12.0/12-buster/docker-entrypoint.sh @@ -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 "$@" diff --git a/2.12.0/12-buster/mm-docker-config.js b/2.12.0/12-buster/mm-docker-config.js new file mode 100644 index 0000000..7ae119c --- /dev/null +++ b/2.12.0/12-buster/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: "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; } diff --git a/2.12.0/14-alpine/Dockerfile b/2.12.0/14-alpine/Dockerfile new file mode 100644 index 0000000..26291a7 --- /dev/null +++ b/2.12.0/14-alpine/Dockerfile @@ -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"] diff --git a/2.12.0/14-alpine/docker-entrypoint.sh b/2.12.0/14-alpine/docker-entrypoint.sh new file mode 100755 index 0000000..5f17a23 --- /dev/null +++ b/2.12.0/14-alpine/docker-entrypoint.sh @@ -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 "$@" diff --git a/2.12.0/14-alpine/mm-docker-config.js b/2.12.0/14-alpine/mm-docker-config.js new file mode 100644 index 0000000..7ae119c --- /dev/null +++ b/2.12.0/14-alpine/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: "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; } diff --git a/2.12.0/14-buster/Dockerfile b/2.12.0/14-buster/Dockerfile new file mode 100644 index 0000000..afe270f --- /dev/null +++ b/2.12.0/14-buster/Dockerfile @@ -0,0 +1,23 @@ +FROM node:14-buster + +RUN set -e; \ + apt update; \ + apt install -y gettext; \ + rm -rf /var/lib/apt/lists/* + +ARG branch=master + +ENV NODE_ENV production +WORKDIR /opt/magic_mirror + +RUN git clone --depth 1 -b ${branch} 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 mm-docker-config.js docker-entrypoint.sh ./ +RUN chmod +x ./docker-entrypoint.sh + +EXPOSE 8080 +ENTRYPOINT ["./docker-entrypoint.sh"] +CMD ["node", "serveronly"] diff --git a/2.12.0/14-buster/docker-entrypoint.sh b/2.12.0/14-buster/docker-entrypoint.sh new file mode 100755 index 0000000..5f17a23 --- /dev/null +++ b/2.12.0/14-buster/docker-entrypoint.sh @@ -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 "$@" diff --git a/2.12.0/14-buster/mm-docker-config.js b/2.12.0/14-buster/mm-docker-config.js new file mode 100644 index 0000000..7ae119c --- /dev/null +++ b/2.12.0/14-buster/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: "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; } diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template new file mode 100644 index 0000000..8991880 --- /dev/null +++ b/Dockerfile-alpine.template @@ -0,0 +1,58 @@ +FROM node:%%TAG%% 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"] diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template new file mode 100644 index 0000000..4733ff8 --- /dev/null +++ b/Dockerfile-debian.template @@ -0,0 +1,23 @@ +FROM node:%%TAG%% + +RUN set -e; \ + apt update; \ + apt install -y gettext; \ + rm -rf /var/lib/apt/lists/* + +ARG branch=master + +ENV NODE_ENV production +WORKDIR /opt/magic_mirror + +RUN git clone --depth 1 -b ${branch} 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 mm-docker-config.js docker-entrypoint.sh ./ +RUN chmod +x ./docker-entrypoint.sh + +EXPOSE 8080 +ENTRYPOINT ["./docker-entrypoint.sh"] +CMD ["node", "serveronly"] \ No newline at end of file diff --git a/README.md b/README.md index d40cf26..1473199 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ In some cases, you want to start the application without an actual app window. I - `latest` - The [latest stable release](https://github.com/MichMich/MagicMirror/releases/latest) of MagicMirror. - `develop` - Image based on the [`develop`](https://github.com/MichMich/MagicMirror/tree/develop) branch. -- `vX.Y.Z`- Specific MagicMirror release. Take a look at the [releases](https://github.com/MichMich/MagicMirror/releases) page in the MagicMirror repository to get the correct version number. +- `vX.Y.Z`- Specific MagicMirror release. There is a `-alpine` tag if you are looking for smaller images. Take a look at the [releases](https://github.com/MichMich/MagicMirror/releases) page in the MagicMirror repository to get the correct version number. > The respective docker images are getting updated daily by a cron job from Travis CI. @@ -116,5 +116,29 @@ and choose 'Localisation options' I'm happy to accept Pull Requests! Please note that this project is released with a [Contributor Code of Conduct](https://github.com/bastilimbach/docker-MagicMirror/blob/master/.github/CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms. +# Usage + +## `update.sh` +``` bash +./update.sh A.B.C,X.Y.Z +``` +Creates directory structure with _Dockerfile_, entrypoint file and _mmm-docker-config.js_ for the specified MagicMirror versions (no leading "v") and for the supported platforms i.e. NodeJS versions 12 and 14 on Debian buster and Alpine. + +## `build.sh` +``` bash +./build.sh 2.12.0 12-buster --push +# or +./build.sh 2.12.0,A.B.C,X.Y.Z 12-buster,12-alpine,14-buster,14-alpine --push +``` +Build Docker images locally. You can specify one or many versions that you want to build on one or many platforms. Building images locally for multiple architectures with the `--load` flag is [currently not possible](https://github.com/docker/buildx/issues/59). If the optional third argument `--push` is set when running the build script it will use `buildx` to build and push the Docker image for the defined architectures. + +## `test-build.sh` +``` bash +./test-build.sh 2.12.0 12-buster +``` + +Build and run specified MagicMirror version on specified platform locally. Exposed on port 80 and with _modules_ and _config_ as volumes in this project's root directory. + + # License [MIT](https://github.com/bastilimbach/docker-MagicMirror/blob/master/LICENSE) ❤️ diff --git a/build.sh b/build.sh index 1ff6a00..828b3d3 100755 --- a/build.sh +++ b/build.sh @@ -1,10 +1,90 @@ #!/bin/bash -set -e +set -euo pipefail -# https://stackoverflow.com/a/51761312/4934537 -latest_release=$(git ls-remote --tags --refs --sort="v:refname" https://github.com/MichMich/MagicMirror.git | tail -n1 | sed 's/.*\///') -if [ "$(docker manifest inspect bastilimbach/docker-magicmirror:"${latest_release}" > /dev/null; echo $?)" != 0 ]; then - docker buildx build --progress plain --platform=linux/amd64,linux/arm64,linux/arm/v7 ${1} --build-arg branch="${latest_release}" -t bastilimbach/docker-magicmirror:"${latest_release}" -t bastilimbach/docker-magicmirror:latest . +# Convert comma delimited cli arguments to arrays +# E.g. ./build.sh 10,12 slim,alpine +# "10,12" becomes "10 12" and "slim,alpine" becomes "slim alpine" +IFS=',' read -ra versions_arg <<< "${1:-}" +IFS=',' read -ra variant_arg <<< "${2:-}" +if [ -n "${3-}" ]; then + push="${3}" +else + push="" fi -docker buildx build --progress plain --platform=linux/amd64,linux/arm64,linux/arm/v7 ${1} --build-arg branch=develop -t bastilimbach/docker-magicmirror:develop . +function build() { + local version + local tag + local variant + local full_tag + version="$1" + shift + variant="$1" + shift + tag="$1" + shift + + full_tag=${tag} + case "$variant" in + *alpine*) full_tag="${version}-alpine" ;; + esac + + echo "Building ${full_tag}..." + branch="${version}" + if [ "${version}" != "master" ] && [ "${version}" != "develop" ]; then + branch="v${version}" + fi + + latest_tag="" + latest_release=$(git ls-remote --tags --refs --sort="v:refname" https://github.com/MichMich/MagicMirror.git | tail -n1 | sed 's/.*\///') + if [ "${latest_release}" = "v${version}" ] && [ "${full_tag}" != *"alpine"* ]; then + latest_tag="-t bastilimbach/docker-magicmirror:latest" + fi + + if [ "${push}" ]; then + docker buildx build --progress plain \ + --platform=linux/amd64,linux/arm64,linux/arm/v7 \ + ${push} \ + --build-arg branch="${branch}" \ + -t bastilimbach/docker-magicmirror:"${full_tag}" \ + ${latest_tag} \ + "${version}/${variant}/" + else + if ! docker build --cpuset-cpus="0,1" \ + --build-arg branch="${branch}" \ + -t bastilimbach/docker-magicmirror:"${full_tag}" \ + ${latest_tag} \ + "${version}/${variant}/"; then + echo "Build of ${full_tag} failed!" + exit 2 + fi + echo "Build of ${full_tag} succeeded." + fi +} + +IFS=' ' read -ra versions <<< "${versions_arg[@]}" +IFS=' ' read -ra variants <<< "${variant_arg[@]}" +for version in "${versions[@]}"; do + tag="${version}" + + for variant in "${variants[@]}"; do + # Skip non-docker directories + [ -f "${version}/${variant}/Dockerfile" ] || continue + + build "${version}" "${variant}" "${tag}" + #test_image "${full_version}" "${variant}" "${tag}" + done + +done + +echo "All builds successful!" + +exit 0 + +# https://stackoverflow.com/a/51761312/4934537 +# latest_release=$(git ls-remote --tags --refs --sort="v:refname" https://github.com/MichMich/MagicMirror.git | tail -n1 | sed 's/.*\///') +# if [ "$(docker manifest inspect bastilimbach/docker-magicmirror:"${latest_release}" > /dev/null; echo $?)" != 0 ]; then +# docker buildx build --progress plain --platform=linux/amd64,linux/arm64,linux/arm/v7 ${1} --build-arg branch="${latest_release}" -t bastilimbach/docker-magicmirror:"${latest_release}" -t bastilimbach/docker-magicmirror:latest . +# fi + +# docker buildx build --progress plain --platform=linux/amd64,linux/arm64,linux/arm/v7 ${1} --build-arg branch=develop -t bastilimbach/docker-magicmirror:develop . diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh old mode 100644 new mode 100755 index 32fddb2..5f17a23 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,8 +1,8 @@ -#!/bin/bash +#!/bin/sh set -e if [ ! "$(ls -A /opt/magic_mirror/modules)" ]; then - cp -Rn /opt/default_modules/. /opt/magic_mirror/modules + cp -R /opt/magic_mirror/default_modules/. /opt/magic_mirror/modules fi if [ ! "$(ls -A /opt/magic_mirror/config)" ]; then diff --git a/test-build.sh b/test-build.sh index a8b7b48..5fea327 100755 --- a/test-build.sh +++ b/test-build.sh @@ -1,10 +1,13 @@ +#!/bin/bash +set -e + rm -rf ./config rm -rf ./modules mkdir config mkdir modules docker rm -f magic_mirror -docker build -t mm:latest . +docker build -t mm:latest ${1}/${2} docker run -d \ --publish 80:8080 \ --restart always \ diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..4940240 --- /dev/null +++ b/update.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -Eeuo pipefail + +cd "$(dirname "$(readlink "$BASH_SOURCE")")" + +versions=( "$@" ) +if [ ${#versions[@]} -eq 0 ]; then + versions=( */ ) +fi +versions=( "${versions[@]%/}" ) + +for version in "${versions[@]}"; do + for variant in \ + 12{-alpine,-buster} \ + 14{-alpine,-buster} \ + ; do + tag="$variant" + template='debian' + case "$variant" in + *alpine*) tag="${variant#alpine}"; template='alpine' ;; + esac + + if [ ! -d "$version/$variant" ]; then + mkdir -p ./$version/$variant + touch ./$version/$variant/Dockerfile + fi + echo $tag + echo $variant + echo $template + + sed -e 's!%%TAG%%!'"$tag"'!g' \ + "./Dockerfile-${template}.template" > "$version/$variant/Dockerfile" + + cp docker-entrypoint.sh $version/$variant/ + cp mm-docker-config.js $version/$variant/ + done +done \ No newline at end of file