2021-03-02 05:16:30 +00:00
|
|
|
FROM node:12-alpine
|
|
|
|
LABEL description="Alpine image to build Nativefier apps"
|
2017-05-19 13:21:16 +00:00
|
|
|
|
2017-11-24 15:28:59 +00:00
|
|
|
|
2021-03-10 23:54:33 +00:00
|
|
|
# Install dependencies and cleanup extraneous files
|
2021-03-02 05:16:30 +00:00
|
|
|
RUN apk update \
|
|
|
|
&& apk add bash wine imagemagick dos2unix \
|
|
|
|
&& rm -rf /var/cache/apk/*
|
|
|
|
|
2017-11-16 19:07:24 +00:00
|
|
|
|
2021-03-10 23:54:33 +00:00
|
|
|
# Use node (1000) as default user not root
|
|
|
|
USER node
|
2021-03-02 05:16:30 +00:00
|
|
|
|
2021-03-10 23:54:33 +00:00
|
|
|
ENV NPM_PACKAGES="/home/node/npm-packages"
|
|
|
|
ENV PATH="$PATH:$NPM_PACKAGES/bin"
|
|
|
|
ENV MANPATH="$MANPATH:$NPM_PACKAGES/share/man"
|
|
|
|
|
|
|
|
# Setup a global packages location for "node" user so we can npm link
|
|
|
|
RUN mkdir $NPM_PACKAGES \
|
|
|
|
&& npm config set prefix $NPM_PACKAGES
|
2017-05-19 13:21:16 +00:00
|
|
|
|
2017-11-24 15:28:59 +00:00
|
|
|
WORKDIR /nativefier
|
2021-03-02 05:16:30 +00:00
|
|
|
|
2021-03-10 23:54:33 +00:00
|
|
|
# Add sources with node as the owner so that it has the power it needs to build in /nativefier
|
|
|
|
COPY --chown=node:node . .
|
2021-03-02 05:16:30 +00:00
|
|
|
|
2021-03-10 23:54:33 +00:00
|
|
|
# Fix line endings that may have gotten mangled in Windows
|
|
|
|
RUN find ./icon-scripts ./src ./app -type f -print0 | xargs -0 dos2unix
|
2017-05-19 13:21:16 +00:00
|
|
|
|
2021-03-10 23:54:33 +00:00
|
|
|
# Link (which will install and build)
|
|
|
|
# Run tests (to ensure we don't Docker build & publish broken stuff)
|
|
|
|
# Cleanup leftover files in this step to not waste Docker layer space
|
|
|
|
# Make sure nativefier is executable
|
|
|
|
RUN npm link \
|
|
|
|
&& npm test \
|
2021-03-11 00:44:40 +00:00
|
|
|
&& rm -rf ~/.npm/_cacache ~/.cache/electron \
|
2021-03-10 23:54:33 +00:00
|
|
|
&& chmod +x $NPM_PACKAGES/bin/nativefier
|
2017-05-19 13:21:16 +00:00
|
|
|
|
2021-03-02 05:16:30 +00:00
|
|
|
# Run a {lin,mac,win} build
|
|
|
|
# 1. to check installation was sucessful
|
|
|
|
# 2. to cache electron distributables and avoid downloads at runtime
|
2021-03-10 23:54:33 +00:00
|
|
|
# Also delete generated apps so they don't get added to the Docker layer
|
|
|
|
# !Important! The `rm -rf` command must be in the same `RUN` command (using an `&&`), to not waste Docker layer space
|
2021-01-30 04:49:52 +00:00
|
|
|
RUN nativefier https://github.com/nativefier/nativefier /tmp/nativefier \
|
|
|
|
&& nativefier -p osx https://github.com/nativefier/nativefier /tmp/nativefier \
|
2021-03-10 23:54:33 +00:00
|
|
|
&& nativefier -p windows https://github.com/nativefier/nativefier /tmp/nativefier \
|
|
|
|
&& rm -rf /tmp/nativefier
|
2021-03-02 05:16:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
RUN echo Generated Electron cache size: $(du -sh ~/.cache/electron) \
|
|
|
|
&& echo Final image size: $(du -sh / 2>/dev/null)
|
2017-05-19 13:21:16 +00:00
|
|
|
|
|
|
|
ENTRYPOINT ["nativefier"]
|
|
|
|
CMD ["--help"]
|