Skip to content

Commit 6173229

Browse files
committed
Merge pull request #93 from GoogleCloudPlatform/jlm/gke-hello
Container Engine hello world sample
2 parents 8f69183 + 5c15096 commit 6173229

File tree

3 files changed

+77
-30
lines changed

3 files changed

+77
-30
lines changed
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2016, 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+
FROM node:4
15+
EXPOSE 8080
16+
COPY server.js .
17+
CMD node server.js

containerengine/hello-world/server.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2016, 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+
'use strict';
15+
16+
// [START all]
17+
var http = require('http');
18+
var handleRequest = function(request, response) {
19+
response.writeHead(200);
20+
response.end('Hello Kubernetes!');
21+
};
22+
var www = http.createServer(handleRequest);
23+
www.listen(process.env.PORT || 8080);
24+
// [END all]

test/appengine/all.test.js

+36-30
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var cwd = process.cwd();
2323
var projectId = process.env.GCLOUD_PROJECT;
2424

2525
function getPath(dir) {
26-
return path.join(cwd, '/../../appengine/', dir);
26+
return path.join(cwd, '/../../', dir);
2727
}
2828

2929
function changeScaling(dir) {
@@ -42,38 +42,38 @@ function changeScaling(dir) {
4242

4343
var sampleTests = [
4444
{
45-
dir: 'analytics',
45+
dir: 'appengine/analytics',
4646
cmd: 'node',
4747
args: ['app.js'],
4848
msg: 'Event tracked.'
4949
},
5050
{
51-
dir: 'bower',
51+
dir: 'appengine/bower',
5252
cmd: 'node',
5353
args: ['server.js'],
5454
msg: 'Express.js + Bower on Google App Engine.'
5555
},
5656
{
57-
dir: 'cloudsql',
57+
dir: 'appengine/cloudsql',
5858
cmd: 'node',
5959
args: ['app.js'],
6060
msg: 'Last 10 visits:',
6161
TRAVIS: true
6262
},
6363
{
64-
dir: 'datastore',
64+
dir: 'appengine/datastore',
6565
cmd: 'node',
6666
args: ['app.js'],
6767
msg: 'Last 10 visits:'
6868
},
6969
{
70-
dir: 'disk',
70+
dir: 'appengine/disk',
7171
cmd: 'node',
7272
args: ['app.js'],
7373
msg: 'Instance:'
7474
},
7575
{
76-
dir: 'express',
76+
dir: 'appengine/express',
7777
deploy: true,
7878
promote: true,
7979
cmd: 'node',
@@ -82,75 +82,75 @@ var sampleTests = [
8282
TRAVIS_NODE_VERSION: '0.10'
8383
},
8484
{
85-
dir: 'express-memcached-session',
85+
dir: 'appengine/express-memcached-session',
8686
cmd: 'node',
8787
args: ['server.js'],
8888
msg: 'Viewed',
8989
TRAVIS_NODE_VERSION: '0.10'
9090
},
9191
{
92-
dir: 'geddy',
92+
dir: 'appengine/geddy',
9393
cmd: 'node',
9494
args: ['node_modules/geddy/bin/cli.js'],
9595
msg: 'Hello, World! Geddy.js on Google App Engine.',
9696
TRAVIS_NODE_VERSION: 'stable'
9797
},
9898
{
99-
dir: 'grunt',
99+
dir: 'appengine/grunt',
100100
deploy: true,
101101
cmd: 'node',
102102
args: ['./src/bin/www'],
103103
msg: 'Hello World! Express.js + Grunt.js on Google App Engine.',
104104
TRAVIS_NODE_VERSION: '0.12'
105105
},
106106
{
107-
dir: 'hello-world',
107+
dir: 'appengine/hello-world',
108108
cmd: 'node',
109109
args: ['app.js'],
110110
msg: 'Hello, world!'
111111
},
112112
{
113-
dir: 'kraken',
113+
dir: 'appengine/kraken',
114114
cmd: 'node',
115115
args: ['server.js'],
116116
msg: 'Hello World! Kraken.js on Google App Engine.',
117117
code: 304
118118
},
119119
{
120-
dir: 'logging',
120+
dir: 'appengine/logging',
121121
cmd: 'node',
122122
args: ['app.js'],
123123
msg: 'Logged'
124124
},
125125
{
126-
dir: 'loopback',
126+
dir: 'appengine/loopback',
127127
cmd: 'node',
128128
args: ['server/server.js'],
129129
msg: 'LoopBack.js on Google App Engine.',
130130
code: 304
131131
},
132132
{
133-
dir: 'mailgun',
133+
dir: 'appengine/mailgun',
134134
cmd: 'node',
135135
args: ['app.js'],
136136
msg: 'Express.js + Mailgun on Google App Engine.'
137137
},
138138
{
139-
dir: 'memcached',
139+
dir: 'appengine/memcached',
140140
cmd: 'node',
141141
args: ['app.js'],
142142
msg: 'Value:',
143143
test: /Value: \d\.\d+/
144144
},
145145
{
146-
dir: 'mongodb',
146+
dir: 'appengine/mongodb',
147147
cmd: 'node',
148148
args: ['server.js'],
149149
msg: 'IPs:',
150150
TRAVIS: true
151151
},
152152
{
153-
dir: 'pubsub',
153+
dir: 'appengine/pubsub',
154154
cmd: 'node',
155155
args: ['app.js'],
156156
msg: 'Messages received by this instance:',
@@ -160,31 +160,31 @@ var sampleTests = [
160160
}
161161
},
162162
{
163-
dir: 'redis',
163+
dir: 'appengine/redis',
164164
cmd: 'node',
165165
args: ['server.js'],
166166
msg: '127.0.0.1'
167167
},
168168
{
169-
dir: 'restify',
169+
dir: 'appengine/restify',
170170
cmd: 'node',
171171
args: ['server.js'],
172172
msg: 'Hello World! Restify.js on Google App Engine.'
173173
},
174174
{
175-
dir: 'sendgrid',
175+
dir: 'appengine/sendgrid',
176176
cmd: 'node',
177177
args: ['app.js'],
178178
msg: 'Express.js + Sendgrid on Google App Engine.'
179179
},
180180
{
181-
dir: 'static-files',
181+
dir: 'appengine/static-files',
182182
cmd: 'node',
183183
args: ['app.js'],
184184
msg: 'This is a static file serving example.'
185185
},
186186
{
187-
dir: 'storage',
187+
dir: 'appengine/storage',
188188
cmd: 'node',
189189
args: ['app.js'],
190190
msg: '<title>Static Files</title>',
@@ -193,24 +193,30 @@ var sampleTests = [
193193
}
194194
},
195195
{
196-
dir: 'webpack',
196+
dir: 'appengine/webpack',
197197
cmd: 'node',
198198
args: ['server.js'],
199199
msg: 'Express.js + Webpack on Google App Engine.'
200200
},
201201
{
202-
dir: 'websockets',
202+
dir: 'appengine/websockets',
203203
cmd: 'node',
204204
args: ['app.js'],
205205
msg: 'Echo demo'
206+
},
207+
{
208+
dir: 'containerengine/hello-world',
209+
cmd: 'node',
210+
args: ['server.js'],
211+
msg: 'Hello Kubernetes!'
206212
}
207213
];
208214

209215
if (process.env.TRAVIS_NODE_VERSION === '0.10') {
210216
// For some reason the "npm install" step for the Sails sample doesn't work on
211217
// Travis when using Node.js stable. It works locally, however.
212218
sampleTests.push({
213-
dir: 'sails',
219+
dir: 'appengine/sails',
214220
cmd: 'node',
215221
args: ['app.js'],
216222
msg: 'Hello World! Sails.js on Google App Engine.',
@@ -220,22 +226,22 @@ if (process.env.TRAVIS_NODE_VERSION === '0.10') {
220226

221227
if (process.env.TRAVIS_NODE_VERSION === 'stable') {
222228
sampleTests.push({
223-
dir: 'hapi',
229+
dir: 'appengine/hapi',
224230
cmd: 'node',
225231
args: ['index.js'],
226232
msg: 'Hello World! Hapi.js on Google App Engine.',
227233
TRAVIS_NODE_VERSION: 'stable'
228234
});
229235
sampleTests.push({
230-
dir: 'koa',
236+
dir: 'appengine/koa',
231237
deploy: true,
232238
cmd: 'node',
233239
args: ['--harmony', 'app.js'],
234240
msg: 'Hello World! Koa.js on Google App Engine.',
235241
TRAVIS_NODE_VERSION: 'stable'
236242
});
237243
sampleTests.push({
238-
dir: 'parse-server',
244+
dir: 'appengine/parse-server',
239245
cmd: 'node',
240246
args: ['server.js'],
241247
msg: 'Hello, world!',
@@ -293,7 +299,7 @@ var port = 8080;
293299
sampleTests.forEach(function (sample) {
294300
sample.env = sample.env || {};
295301
sample.env.PORT = port;
296-
if (sample.dir === 'parse-server') {
302+
if (sample.dir === 'appengine/parse-server') {
297303
sample.env.SERVER_URL = sample.env.SERVER_URL + port + '/parse';
298304
}
299305
port++;

0 commit comments

Comments
 (0)