forked from GoogleChromeLabs/application-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
69 lines (69 loc) · 2.95 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
# Dockerfile extending the generic Node image with application files for a
# single application.
FROM beta.gcr.io/google_appengine/nodejs
# Check to see if the the version included in the base runtime satisfies \
# >=4.1.0, if not then do an npm install of the latest available \
# version that satisfies it. \
RUN npm install https://storage.googleapis.com/gae_node_packages/semver.tar.gz && \
(node -e 'var semver = require("semver"); \
if (!semver.satisfies(process.version, ">=4.1.0")) \
process.exit(1);' || \
(version=$(curl -L https://storage.googleapis.com/gae_node_packages/node_versions | \
node -e ' \
var semver = require("semver"); \
var http = require("http"); \
var spec = process.argv[1]; \
var latest = ""; \
var versions = ""; \
var selected_version; \
\
function verifyBinary(version) { \
var options = { \
"host": "storage.googleapis.com", \
"method": "HEAD", \
"path": "/gae_node_packages/node-" + version + \
"-linux-x64.tar.gz" \
}; \
var req = http.request(options, function (res) { \
if (res.statusCode == 404) { \
console.error("Binaries for Node satisfying version " + \
version + " are not available."); \
process.exit(1); \
} \
}); \
req.end(); \
} \
function satisfies(version) { \
if (semver.satisfies(version, spec)) { \
process.stdout.write(version); \
verifyBinary(version); \
return true; \
} \
} \
process.stdin.on("data", function(data) { \
versions += data; \
}); \
process.stdin.on("end", function() { \
versions = \
versions.split("\n").sort().reverse(); \
if (!versions.some(satisfies)) { \
console.error("No version of Node found satisfying: " + \
spec); \
process.exit(1); \
} \
});' \
">=4.1.0") && \
rm -rf /nodejs/* && \
(curl https://storage.googleapis.com/gae_node_packages/node-$version-linux-x64.tar.gz | \
tar xzf - -C /nodejs --strip-components=1 \
) \
) \
)
COPY . /app/
# You have to specify "--unsafe-perm" with npm install
# when running as root. Failing to do this can cause
# install to appear to succeed even if a preinstall
# script fails, and may have other adverse consequences
# as well.
RUN npm --unsafe-perm install
CMD npm start