Skip to content

Commit 9b611fb

Browse files
Merge pull request GoogleCloudPlatform#112 from GoogleCloudPlatform/squashStaticContent
A sample that shows how to serve static via nginx on app engine flex.
2 parents d9ed32b + c21af56 commit 9b611fb

File tree

13 files changed

+2211
-0
lines changed

13 files changed

+2211
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Static content and Google App Engine Flexible Environment
2+
3+
This sample application demonstrates how to serve static content with Google App
4+
Engine Flexible Environment.
5+
6+
## Prerequisites
7+
8+
- Install [`composer`](https://getcomposer.org)
9+
- Install dependencies by running:
10+
11+
```sh
12+
$ composer install
13+
```
14+
15+
## Deploy to App Engine
16+
17+
**Prerequisites**
18+
19+
- Install the [Google Cloud SDK](https://developers.google.com/cloud/sdk/).
20+
21+
**Deploy with gcloud**
22+
23+
```
24+
$ gcloud config set project YOUR_PROJECT_ID
25+
$ gcloud preview app deploy
26+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
/**
3+
* Copyright 2015 Google Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
use Silex\Application;
19+
use Silex\Provider\TwigServiceProvider;
20+
use Symfony\Component\HttpFoundation\Request;
21+
22+
// create the Silex application
23+
$app = new Application();
24+
$app->register(new TwigServiceProvider());
25+
$app['twig.path'] = [ __DIR__ ];
26+
27+
$app->get('/', function (Application $app, Request $request) {
28+
/** @var Twig_Environment $twig */
29+
$twig = $app['twig'];
30+
return $twig->render('index.html.twig',
31+
['ip' => $request->getClientIps()[0]]);
32+
});
33+
34+
return $app;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
runtime: php
2+
vm: true
3+
4+
runtime_config:
5+
document_root: web
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"require": {
3+
"silex/silex": "^1.3",
4+
"twig/twig": "^1.24"
5+
},
6+
"require-dev": {
7+
"phpunit/phpunit": "~4",
8+
"guzzlehttp/guzzle": "^6.2",
9+
"google/cloud-tools": "^0.1.0"
10+
}
11+
}

0 commit comments

Comments
 (0)