@@ -9,10 +9,46 @@ COPY /docker/bashrc_to_docker /root/.bashrc
99ARG DEBIAN_FRONTEND=noninteractive
1010
1111RUN apt-get update -q && apt-get install -q -y \
12+ curl apt-transport-https apt-utils \
1213 gcc \
1314 gettext \
1415 postgresql-client libpq-dev \
15- vim git curl less psmisc
16+ vim less psmisc \
17+ python
18+
19+ WORKDIR /home/download
20+ ARG NODEREPO="node_6.x"
21+ ARG DISTRO="jessie"
22+ # Only newest package kept in nodesource repo. Cannot pin to version using apt!
23+ # See https://github.com/nodesource/distributions/issues/33
24+ # RUN curl -sSO https://deb.nodesource.com/gpgkey/nodesource.gpg.key
25+ # RUN apt-key add nodesource.gpg.key
26+ # RUN echo "deb https://deb.nodesource.com/${NODEREPO} ${DISTRO} main" > /etc/apt/sources.list.d/nodesource.list
27+ # RUN echo "deb-src https://deb.nodesource.com/${NODEREPO} ${DISTRO} main" >> /etc/apt/sources.list.d/nodesource.list
28+ # RUN apt-get update -q && apt-get install -q -y 'nodejs=6.11.3*'
29+
30+ # So we have to download specific package in order to pin version of node.
31+ # dpkg doesn't install package dependencies automatically, we have to do it.
32+ # This nodejs package has a dependency on the 'python' package, installed above.
33+ # Since this is a python:2.7-slim image, you would think python packages
34+ # are installed. But the Dockerfile installs Python from source, not packages.
35+
36+ # jessie specific version not provided starting with 6.11.3
37+ # ARG NODE_PACKAGE=nodejs_6.11.2-1nodesource1~jessie1_amd64.deb
38+ ARG NODE_PACKAGE=nodejs_6.11.3-1nodesource1_amd64.deb
39+ RUN curl -sSO "https://deb.nodesource.com/node_6.x/pool/main/n/nodejs/${NODE_PACKAGE}"
40+ RUN dpkg -i ${NODE_PACKAGE}
41+
42+ # npm upgrade doesn't work due to bug in nodejs .deb package!
43+ # Must install nodejs at terminal for npm upgrade to work!
44+ # RUN npm install -g npm
45+ # RUN npm --version
46+
47+ RUN curl -sSO https://dl.yarnpkg.com/debian/pubkey.gpg
48+ RUN apt-key add pubkey.gpg
49+ RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
50+
51+ RUN apt-get update -q && apt-get install -q -y 'yarn=1.0.2*'
1652
1753RUN rm -rf /var/lib/apt/lists/*
1854
@@ -30,15 +66,6 @@ ARG HOME=/home/thresher
3066RUN groupadd -g ${GROUP_ID} ${USER} && \
3167 useradd --shell /bin/bash --home ${HOME} -u ${USER_ID} -g ${GROUP_ID} ${USER}
3268
33- WORKDIR /home/download
34- # https://nodejs.org/dist/v6.10.3/node-v6.10.3-linux-x64.tar.xz
35- ARG NODE_VERSION=v6.10.3
36- ARG NODE_FILE=node-${NODE_VERSION}-linux-x64.tar.xz
37- # This merges files into /usr/local/{bin,include,lib,share}
38- # So node is installed for all users
39- RUN curl -O https://nodejs.org/dist/${NODE_VERSION}/${NODE_FILE}
40- RUN tar -C /usr/local --strip-components 1 -xf ${NODE_FILE}
41-
4269# Let Django copy to static dir as regular user
4370WORKDIR /var/www
4471RUN chown ${USER}:${USER} /var/www
@@ -47,20 +74,18 @@ ENV PYTHONPATH /home/thresher
4774# note: Development config mounts the git repo root on this path.
4875# Copy minimal files needed to npm install to try
4976# and re-use cache
77+ ENV WEBPACK_BUILD_DIR /home/thresher
5078WORKDIR /home/thresher
79+ RUN chown ${USER}:${USER} /home/thresher
5180COPY /package.json /home/thresher
52- RUN chown -R ${USER}:${USER} /home/thresher
81+ COPY /yarn.lock /home/thresher
5382
54- ENV WEBPACK_BUILD_DIR /home/thresher
55- WORKDIR /home/thresher
5683USER ${USER}
57- RUN npm install
84+ RUN yarn install
5885
5986# Now copy the rest of the repo into the image - any file change breaks build cache
87+ # .dockerignore must exclude node_modules/ and dist/
6088COPY / /home/thresher
61- USER root
62- RUN chown -R ${USER}:${USER} /home/thresher
63- USER ${USER}
6489RUN npm run deploy:quiet
6590
6691COPY /docker/bashrc_to_docker ${HOME}/.bashrc
0 commit comments