@@ -9,10 +9,46 @@ COPY /docker/bashrc_to_docker /root/.bashrc
9
9
ARG DEBIAN_FRONTEND=noninteractive
10
10
11
11
RUN apt-get update -q && apt-get install -q -y \
12
+ curl apt-transport-https apt-utils \
12
13
gcc \
13
14
gettext \
14
15
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*'
16
52
17
53
RUN rm -rf /var/lib/apt/lists/*
18
54
@@ -30,15 +66,6 @@ ARG HOME=/home/thresher
30
66
RUN groupadd -g ${GROUP_ID} ${USER} && \
31
67
useradd --shell /bin/bash --home ${HOME} -u ${USER_ID} -g ${GROUP_ID} ${USER}
32
68
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
-
42
69
# Let Django copy to static dir as regular user
43
70
WORKDIR /var/www
44
71
RUN chown ${USER}:${USER} /var/www
@@ -47,20 +74,18 @@ ENV PYTHONPATH /home/thresher
47
74
# note: Development config mounts the git repo root on this path.
48
75
# Copy minimal files needed to npm install to try
49
76
# and re-use cache
77
+ ENV WEBPACK_BUILD_DIR /home/thresher
50
78
WORKDIR /home/thresher
79
+ RUN chown ${USER}:${USER} /home/thresher
51
80
COPY /package.json /home/thresher
52
- RUN chown -R ${USER}:${USER} /home/thresher
81
+ COPY /yarn.lock /home/thresher
53
82
54
- ENV WEBPACK_BUILD_DIR /home/thresher
55
- WORKDIR /home/thresher
56
83
USER ${USER}
57
- RUN npm install
84
+ RUN yarn install
58
85
59
86
# Now copy the rest of the repo into the image - any file change breaks build cache
87
+ # .dockerignore must exclude node_modules/ and dist/
60
88
COPY / /home/thresher
61
- USER root
62
- RUN chown -R ${USER}:${USER} /home/thresher
63
- USER ${USER}
64
89
RUN npm run deploy:quiet
65
90
66
91
COPY /docker/bashrc_to_docker ${HOME}/.bashrc
0 commit comments