-
Notifications
You must be signed in to change notification settings - Fork 55
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
00aff5b
66eb48f
6e791ed
991a098
eff0383
61dfc31
ca2ab3a
9b436a2
05a0a00
b51d1a7
5b6d1e9
6ca7b8f
4bef007
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.github | ||
config | ||
modules | ||
build.sh | ||
test-build.sh | ||
Original file line number | Diff line number | Diff line change | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,23 +1,55 @@ | |||||||||||
FROM node:12-buster | |||||||||||
|
|||||||||||
RUN set -e; \ | |||||||||||
apt update; \ | |||||||||||
apt install -y gettext; \ | |||||||||||
rm -rf /var/lib/apt/lists/* | |||||||||||
FROM node:12-alpine AS BUILD_IMAGE | |||||||||||
|
|||||||||||
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 | |||||||||||
# 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 . \ | |||||||||||
&& apk del git | |||||||||||
This comment was marked as resolved.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True. I will remove Build times on my machine
Between the builds I did run |
|||||||||||
|
|||||||||||
COPY mm-docker-config.js docker-entrypoint.sh ./ | |||||||||||
RUN chmod +x ./docker-entrypoint.sh | |||||||||||
# 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 \ | |||||||||||
config \ | |||||||||||
css \ | |||||||||||
fonts \ | |||||||||||
index.html \ | |||||||||||
js \ | |||||||||||
node_modules \ | |||||||||||
package.json \ | |||||||||||
package-lock.json \ | |||||||||||
serveronly \ | |||||||||||
translations \ | |||||||||||
vendor /opt/magic_mirror/dist | |||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer to copy over all files and just delete the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what the benefit of this would be. Adding specifically the files and folders required is what docker recommends and I think it makes clearer what is used and required for MagicMirror to run and what can be left aside. Also, if the structure of MagicMirror changes or other folders are added we would have to update the Dockerfile to remove them as well, whereas now we have to add them if they are required for it to work, otherwise there's no change needed. In short, even though it's quite the copying taking place it is much more tranparent what is added to the docker image. |
|||||||||||
|
|||||||||||
|
|||||||||||
FROM node:12-alpine | |||||||||||
|
|||||||||||
WORKDIR /opt/magic_mirror | |||||||||||
|
|||||||||||
RUN set -x \ | |||||||||||
&& apk add --no-cache --update libintl \ | |||||||||||
&& apk add --no-cache --virtual build_deps gettext \ | |||||||||||
&& apk del build_deps | |||||||||||
|
|||||||||||
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"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
rm -rf ./config | ||
rm -rf ./modules | ||
mkdir config | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)