build ionic in a Dockerfile

Is ionic a bit a bitch when it comes to dependencies and the building process? Yes. But it has to be, as so many things depend on the environment. The following Dockerfile works for me (as opposed to many others), including using official node or alpine images.

FROM debian:jessie-slim

RUN apt-get update && apt-get install curl sudo -y
RUN curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
RUN sudo apt-get install -y nodejs
RUN npm install -g cordova
RUN npm install -g ionic

ADD src /build/src
ADD package.json /build/package.json
ADD typings /build/typings
ADD resources /build/resources

ADD config.xml /build/config.xml
ADD ionic.config.json /build/ionic.config.json
ADD tsconfig.json /build/tsconfig.json
ADD tslint.json /build/tslint.json

RUN cordova telemetry on
RUN cd /build && npm install
RUN mkdir /build/www
RUN cd /build && ionic state restore
RUN cd /build && ionic build browser --prod
ENTRYPOINT /bin/bash