├── .gitignore ├── CONTRIBUTORS ├── LICENSE ├── vertx-example ├── app.yaml ├── Dockerfile └── server.js ├── CONTRIBUTING.md ├── README.md └── docker └── Dockerfile /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # People who have agreed to one of the CLAs and can contribute patches. 2 | # The AUTHORS file lists the copyright holders; this file 3 | # lists people. For example, Google employees are listed here 4 | # but not in AUTHORS, because Google holds the copyright. 5 | # 6 | # https://developers.google.com/open-source/cla/individual 7 | # https://developers.google.com/open-source/cla/corporate 8 | # 9 | # Names should be added to this file as: 10 | # Name 11 | 12 | Ray Tsang 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 Google Inc. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /vertx-example/app.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | runtime: custom 16 | vm: true 17 | api_version: 1 18 | 19 | -------------------------------------------------------------------------------- /vertx-example/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | FROM saturnism/appengine-vertx-runtime 16 | 17 | COPY . /app 18 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Want to contribute? Great! First, read this page (including the small print at the end). 2 | 3 | ### Before you contribute 4 | Before we can use your code, you must sign the 5 | [Google Individual Contributor License Agreement](https://developers.google.com/open-source/cla/individual?csw=1) 6 | (CLA), which you can do online. The CLA is necessary mainly because you own the 7 | copyright to your changes, even after your contribution becomes part of our 8 | codebase, so we need your permission to use and distribute your code. We also 9 | need to be sure of various other things—for instance that you'll tell us if you 10 | know that your code infringes on other people's patents. You don't have to sign 11 | the CLA until after you've submitted your code for review and a member has 12 | approved it, but you must do it before we can put your code into our codebase. 13 | Before you start working on a larger contribution, you should get in touch with 14 | us first through the issue tracker with your idea so that we can help out and 15 | possibly guide you. Coordinating up front makes it much easier to avoid 16 | frustration later on. 17 | 18 | ### Code reviews 19 | All submissions, including submissions by project members, require review. We 20 | use Github pull requests for this purpose. 21 | 22 | ### The small print 23 | Contributions made by corporations are covered by a different agreement than 24 | the one above, the Software Grant and Corporate Contributor License Agreement. 25 | -------------------------------------------------------------------------------- /vertx-example/server.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | var vertx = require('vertx'); 16 | 17 | var console = require('vertx/console'); 18 | var routes = new vertx.RouteMatcher(); 19 | 20 | // Health Check 21 | routes.get('/_ah/health', function(req) { 22 | req.response.end("ok"); 23 | }); 24 | 25 | // Start Hook, called before App Engine route traffic to this instance. 26 | routes.get('/_ah/start', function(req) { 27 | console.log("Starting..."); 28 | req.response.end("ok"); 29 | }); 30 | 31 | // Stop Hook, called before App Engine shutdown this instance. 32 | routes.get('/_ah/stop', function(req) { 33 | console.log("Stopping..."); 34 | req.response.end("ok"); 35 | }); 36 | 37 | // Catch all - serve the index page 38 | routes.getWithRegEx('.*', function(req) { 39 | req.response.headers['Content-Type'] = "text/html"; 40 | req.response.end("Hello WorldHello World"); 41 | }); 42 | 43 | vertx.createHttpServer().requestHandler(routes).listen(8080); 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Google App Engine Managed VM Vert.x Runtime Example 2 | =================================================== 3 | 4 | This is an example [App Engine Managed VM](https://cloud.google.com/appengine/docs/managed-vms/) custom runtime for [Vert.x](http://vertx.io/). The runtime example can be used to deploy Vert.x applications. 5 | 6 | This is not an official Google product. 7 | 8 | What is AppEngine Managed VM? 9 | ----------------------------- 10 | Google AppEngine is a scalable platform-as-a-service that runs your application within Google's infrastructure. AppEngine Managed VM lets you run your application with custom runtimes, such as NodeJS, Ruby, Java EE 7, or in this case, Vert.x. 11 | 12 | Vert.x Custom Runtime 13 | --------------------- 14 | The Vert.x custom runtime is stored in the docker/ directory. To build the custom runtime, run: 15 | 16 | $ cd docker/ 17 | $ docker build -t appengine-vertx-runtime . 18 | 19 | Running Vert.x Application 20 | -------------------------- 21 | An example Vert.x application is stored in the vertx-example/ directory. 22 | 23 | To run this application locally on http://localhost:8080: 24 | 25 | $ cd vertx-example/ 26 | $ gcloud preview app run . 27 | 28 | To deploy this application to a Google Cloud Platform project: 29 | 30 | $ cd vertx-example/ 31 | $ gcloud preview app deploy --project YOUR_PROJECT_ID . 32 | 33 | Dockerless Deployment 34 | --------------------- 35 | If you don't have Docker installed - don't worry. Google App Engine can deploy with a `--remote` argument 36 | where Google App Engine can provision a build server to build the runtime for you: 37 | 38 | $ cd vertx-example/ 39 | $ gcloud preview app deploy --project YOUR_PROJECT_ID --remote app.yaml 40 | 41 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | FROM google/debian:wheezy 16 | ENV DEBIAN_FRONTEND noninteractive 17 | 18 | ENV VERTX_VERSION 2.1.4 19 | ENV VERTX_HOME /opt/vertx 20 | ENV DEPLOYMENTS_HOME /app 21 | 22 | RUN apt-get -q update && \ 23 | apt-get install --no-install-recommends -y -q ca-certificates curl openjdk-7-jre-headless && \ 24 | apt-get clean && \ 25 | rm /var/lib/apt/lists/*_* 26 | 27 | RUN useradd -ms /bin/bash vertx 28 | RUN mkdir -p ${VERTX_HOME} ${DEPLOYMENTS_HOME} /var/log/app_engine/custom_logs 29 | RUN chown vertx:vertx ${VERTX_HOME} ${DEPLOYMENTS_HOME} /var/log/app_engine/custom_logs 30 | 31 | USER vertx 32 | 33 | RUN mkdir -p ${VERTX_HOME} && (curl -0L http://dl.bintray.com/vertx/downloads/vert.x-${VERTX_VERSION}.tar.gz | tar -C ${VERTX_HOME} --strip-components=1 -zx) 34 | RUN sed -i "s,%t,/var/log/app_engine/custom_logs/,g" ${VERTX_HOME}/conf/logging.properties 35 | 36 | WORKDIR ${DEPLOYMENTS_HOME} 37 | 38 | EXPOSE 8080 39 | 40 | ENV RUN_FILE server.js 41 | 42 | CMD [] 43 | VOLUME ["/var/log/app_engine"] 44 | #ENTRYPOINT ["${VERTX_HOME}/bin/vertx", "${DEPLOYMENTS_HOME}/${RUN_FILE}"] 45 | CMD ["${VERTX_HOME}/bin/vertx", "run", "${DEPLOYMENTS_HOME}/${RUN_FILE}"] 46 | --------------------------------------------------------------------------------