-
Notifications
You must be signed in to change notification settings - Fork 28
/
Dockerfile
134 lines (116 loc) · 4.01 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
FROM alpine:3.4
LABEL version="1.0.0" \
node="v7.7" \
os="Alpine v3.4" \
description="Node v7.7 compiled from source running on Alpine v3.4"
ENV TERM=xterm \
NLS_LANG=American_America.AL32UTF8 \
LANG=C.UTF-8 \
LANGUAGE=C.UTF-8 \
LC_ALL=C.UTF-8 \
TIMEZONE=America/Denver
ENV NODE_VERSION=v7.7.4 \
NODE_PREFIX=/usr/local
RUN set -x \
&& echo "http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& echo "http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
&& apk update \
&& apk add \
ca-certificates \
curl \
g++ \
gcc \
git \
gnupg \
libgcc \
libstdc++ \
linux-headers \
make \
mercurial \
openssh \
paxctl \
python \
shadow \
subversion \
sudo \
tar
##############################################################################
# Install Node & NPM
# Based on https://github.com/mhart/alpine-node/blob/master/Dockerfile (thank you)
##############################################################################
RUN set -x \
# Download and validate the NodeJs source
&& for key in \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
FD3A5288F042B6850C66B31F09FE44734EB7990E \
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
B9AE9905FFD7803F25714661B63B535A4C206CA9 \
56730D5401028683275BD23C23EFEFE93C4CFFFE \
; do \
gpg --keyserver pgp.mit.edu --recv-keys "$key"|| \
gpg --keyserver keyserver.pgp.com --recv-keys "$key" || \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" ; \
done \
&& mkdir /node_src \
&& cd /node_src \
&& curl -o node-${NODE_VERSION}.tar.gz -sSL https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}.tar.gz \
&& curl -o SHASUMS256.txt.asc -sSL https://nodejs.org/dist/${NODE_VERSION}/SHASUMS256.txt.asc \
&& gpg --verify SHASUMS256.txt.asc \
&& grep node-${NODE_VERSION}.tar.gz SHASUMS256.txt.asc | sha256sum -c -
RUN set -x \
# Compile and install
&& cd /node_src \
&& tar -zxf node-${NODE_VERSION}.tar.gz \
&& cd node-${NODE_VERSION} \
&& export GYP_DEFINES="linux_use_gold_flags=0" \
&& ./configure --prefix=${NODE_PREFIX} \
&& NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) \
&& make -j${NPROC} -C out mksnapshot BUILDTYPE=Release \
&& paxctl -cm out/Release/mksnapshot \
&& make -j${NPROC} \
&& make install \
&& paxctl -cm ${NODE_PREFIX}/bin/node
RUN set -x \
# Install node packages
&& npm install --silent -g \
gulp-cli \
grunt-cli \
bower \
markdown-styles \
yarn
##############################################################################
# users
##############################################################################
RUN set -x \
# Create a dev user to use as the directory owner
&& addgroup dev \
&& adduser -D -s /bin/sh -G dev dev \
&& echo "dev:password" | chpasswd \
# Setup wrapper scripts
&& curl -o /run-as-user https://raw.githubusercontent.com/mkenney/docker-scripts/master/container/run-as-user \
&& chmod 0755 /run-as-user
##############################################################################
# ~ fin ~
##############################################################################
RUN set -x \
&& apk del \
curl \
gnupg \
linux-headers \
paxctl \
python \
tar \
&& find ${NODE_PREFIX}/lib/node_modules/npm -name test -o -name .bin -type d | xargs rm -rf \
&& rm -rf \
/node_src \
/tmp/* \
/var/cache/apk/* \
${NODE_PREFIX}/lib/node_modules/npm/man \
${NODE_PREFIX}/lib/node_modules/npm/doc \
${NODE_PREFIX}/lib/node_modules/npm/html
VOLUME /src
WORKDIR /src
ENTRYPOINT ["/run-as-user"]
CMD ["/usr/local/bin/npm"]