Skip to content
This repository was archived by the owner on Sep 10, 2022. It is now read-only.

Commit 49e6cdb

Browse files
committed
Add Dockerfile, app.yaml, other configs.
1 parent bceddce commit 49e6cdb

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
.dockerignore
3+
Dockerfile
4+
.git
5+
.hg
6+
.svn

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33
*.pyc
44
dist
55
tests
6+
npm-debug.log

Dockerfile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Dockerfile extending the generic Node image with application files for a
2+
# single application.
3+
FROM beta.gcr.io/google_appengine/nodejs
4+
# Check to see if the the version included in the base runtime satisfies \
5+
# >=4.1.0, if not then do an npm install of the latest available \
6+
# version that satisfies it. \
7+
RUN npm install https://storage.googleapis.com/gae_node_packages/semver.tar.gz && \
8+
(node -e 'var semver = require("semver"); \
9+
if (!semver.satisfies(process.version, ">=4.1.0")) \
10+
process.exit(1);' || \
11+
(version=$(curl -L https://storage.googleapis.com/gae_node_packages/node_versions | \
12+
node -e ' \
13+
var semver = require("semver"); \
14+
var http = require("http"); \
15+
var spec = process.argv[1]; \
16+
var latest = ""; \
17+
var versions = ""; \
18+
var selected_version; \
19+
\
20+
function verifyBinary(version) { \
21+
var options = { \
22+
"host": "storage.googleapis.com", \
23+
"method": "HEAD", \
24+
"path": "/gae_node_packages/node-" + version + \
25+
"-linux-x64.tar.gz" \
26+
}; \
27+
var req = http.request(options, function (res) { \
28+
if (res.statusCode == 404) { \
29+
console.error("Binaries for Node satisfying version " + \
30+
version + " are not available."); \
31+
process.exit(1); \
32+
} \
33+
}); \
34+
req.end(); \
35+
} \
36+
function satisfies(version) { \
37+
if (semver.satisfies(version, spec)) { \
38+
process.stdout.write(version); \
39+
verifyBinary(version); \
40+
return true; \
41+
} \
42+
} \
43+
process.stdin.on("data", function(data) { \
44+
versions += data; \
45+
}); \
46+
process.stdin.on("end", function() { \
47+
versions = \
48+
versions.split("\n").sort().reverse(); \
49+
if (!versions.some(satisfies)) { \
50+
console.error("No version of Node found satisfying: " + \
51+
spec); \
52+
process.exit(1); \
53+
} \
54+
});' \
55+
">=4.1.0") && \
56+
rm -rf /nodejs/* && \
57+
(curl https://storage.googleapis.com/gae_node_packages/node-$version-linux-x64.tar.gz | \
58+
tar xzf - -C /nodejs --strip-components=1 \
59+
) \
60+
) \
61+
)
62+
COPY . /app/
63+
# You have to specify "--unsafe-perm" with npm install
64+
# when running as root. Failing to do this can cause
65+
# install to appear to succeed even if a preinstall
66+
# script fails, and may have other adverse consequences
67+
# as well.
68+
RUN npm --unsafe-perm install
69+
CMD npm start

app.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2015, Google, Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
#
14+
# [START app_yaml]
15+
runtime: custom
16+
vm: true
17+
api_version: 1
18+
env_variables:
19+
PORT: 8080
20+
21+
automatic_scaling:
22+
min_num_instances: 2
23+
max_num_instances: 20
24+
cool_down_period_sec: 60
25+
cpu_utilization:
26+
target_utilization: 0.5
27+
# [END app_yaml]

0 commit comments

Comments
 (0)