2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-12-22 10:08:55 +00:00
nativefier/Dockerfile
Adam Weeden 8f9135312b
Docker: fix Windows builds (fix #997), line endings, switch to Alpine (PR #1122)
- Docker builds for Windows are fixed (fixes #997)
- Switched over to use Alpine (as was indicated as desired in https://github.com/nativefier/nativefier/issues/375#issuecomment-304247033) - which may mean #375 is fixed as well.
- Fixed bug where Docker has the wrong line endings when copying from a Windows host
- Fixed the invalid `arm` arch to `armv7l`
- Add `npm t` to the docker build to ensure tests pass before we start trying to do builds
- Add a message to help the user when trying to build Mac apps on Windows as a non-Admin (currently an unhelpful exception)

Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>
2021-03-02 00:16:30 -05:00

47 lines
1.4 KiB
Docker

FROM node:12-alpine
LABEL description="Alpine image to build Nativefier apps"
# Install dependencies
RUN apk update \
&& apk add bash wine imagemagick dos2unix \
&& rm -rf /var/cache/apk/*
WORKDIR /nativefier
# Add sources
COPY . .
# Fix line endings that may have gotten mangled in Windows
RUN find ./icon-scripts ./src ./app -type f -print0 | xargs -0 dos2unix
# Build nativefier and link globally
WORKDIR /nativefier/app
RUN npm install
WORKDIR /nativefier
# Install (note that we had to manually install in `app` before, as `prepare` won't run as root)
# Also, running tests, to ensure we don't Docker build & publish broken stuff
RUN npm install && npm run build && npm test && npm link
# Cleanup test artifacts
RUN rm -rf /tmp/nativefier*
# Use 1000 as default user not root
USER 1000
# Run a {lin,mac,win} build
# 1. to check installation was sucessful
# 2. to cache electron distributables and avoid downloads at runtime
RUN nativefier https://github.com/nativefier/nativefier /tmp/nativefier \
&& nativefier -p osx https://github.com/nativefier/nativefier /tmp/nativefier \
&& nativefier -p windows https://github.com/nativefier/nativefier /tmp/nativefier
RUN echo Generated Electron cache size: $(du -sh ~/.cache/electron) \
&& rm -rf /tmp/nativefier \
&& echo Final image size: $(du -sh / 2>/dev/null)
ENTRYPOINT ["nativefier"]
CMD ["--help"]