mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #63 from brendandburns/examples
Added the example dockerfiles.
This commit is contained in:
commit
880059fb8a
7
examples/guestbook/php-redis/Dockerfile
Normal file
7
examples/guestbook/php-redis/Dockerfile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
FROM brendanburns/php
|
||||||
|
|
||||||
|
ADD index.php /var/www/index.php
|
||||||
|
ADD controllers.js /var/www/controllers.js
|
||||||
|
ADD index.html /var/www/index.html
|
||||||
|
|
||||||
|
CMD /run.sh
|
29
examples/guestbook/php-redis/controllers.js
Normal file
29
examples/guestbook/php-redis/controllers.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
var redisApp = angular.module('redis', ['ui.bootstrap']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
function RedisController() {}
|
||||||
|
|
||||||
|
RedisController.prototype.onRedis = function() {
|
||||||
|
this.scope_.messages.push(this.scope_.msg);
|
||||||
|
this.scope_.msg = "";
|
||||||
|
var value = this.scope_.messages.join();
|
||||||
|
this.http_.get("/index.php?cmd=set&key=messages&value=" + value)
|
||||||
|
.success(angular.bind(this, function(data) {
|
||||||
|
this.scope_.redisResponse = "Updated.";
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
redisApp.controller('RedisCtrl', function ($scope, $http, $location) {
|
||||||
|
$scope.controller = new RedisController();
|
||||||
|
$scope.controller.scope_ = $scope;
|
||||||
|
$scope.controller.location_ = $location;
|
||||||
|
$scope.controller.http_ = $http;
|
||||||
|
|
||||||
|
$scope.controller.http_.get("/index.php?cmd=get&key=messages")
|
||||||
|
.success(function(data) {
|
||||||
|
console.log(data);
|
||||||
|
$scope.messages = data.data.split(",");
|
||||||
|
});
|
||||||
|
});
|
25
examples/guestbook/php-redis/index.html
Normal file
25
examples/guestbook/php-redis/index.html
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<html ng-app="redis">
|
||||||
|
<head>
|
||||||
|
<title>Guestbook</title>
|
||||||
|
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular.min.js"></script>
|
||||||
|
<script src="/controllers.js"></script>
|
||||||
|
<script src="ui-bootstrap-tpls-0.10.0.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body ng-controller="RedisCtrl">
|
||||||
|
<div style="width: 50%; margin-left: 20px">
|
||||||
|
<h2>Guestbook</h2>
|
||||||
|
<form>
|
||||||
|
<fieldset>
|
||||||
|
<input ng-model="msg" placeholder="Messages" class="form-control" type="text" name="input"><br>
|
||||||
|
<button type="button" class="btn btn-primary" ng-click="controller.onRedis()">Submit</button>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
<div>
|
||||||
|
<div ng-repeat="msg in messages">
|
||||||
|
{{msg}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
37
examples/guestbook/php-redis/index.php
Normal file
37
examples/guestbook/php-redis/index.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?
|
||||||
|
|
||||||
|
set_include_path('.:/usr/share/php:/usr/share/pear:/vendor/predis');
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
|
||||||
|
require 'predis/autoload.php';
|
||||||
|
|
||||||
|
if (isset($_GET['cmd']) === true) {
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
if ($_GET['cmd'] == 'set') {
|
||||||
|
$client = new Predis\Client([
|
||||||
|
'scheme' => 'tcp',
|
||||||
|
'host' => getenv('SERVICE_HOST'),
|
||||||
|
'port' => getenv('REDISMASTER_SERVICE_PORT'),
|
||||||
|
]);
|
||||||
|
$client->set($_GET['key'], $_GET['value']);
|
||||||
|
print('{"message": "Updated"}');
|
||||||
|
} else {
|
||||||
|
$read_port = getenv('REDISMASTER_SERVICE_PORT');
|
||||||
|
|
||||||
|
if (isset($_ENV['REDISSLAVE_SERVICE_PORT'])) {
|
||||||
|
$read_port = getenv('REDISSLAVE_SERVICE_PORT');
|
||||||
|
}
|
||||||
|
$client = new Predis\Client([
|
||||||
|
'scheme' => 'tcp',
|
||||||
|
'host' => getenv('SERVICE_HOST'),
|
||||||
|
'port' => $read_port,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$value = $client->get($_GET['key']);
|
||||||
|
print('{"data": "' . $value . '"}');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
phpinfo();
|
||||||
|
} ?>
|
7
examples/guestbook/redis-slave/Dockerfile
Normal file
7
examples/guestbook/redis-slave/Dockerfile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
FROM dockerfile/redis
|
||||||
|
|
||||||
|
ADD run.sh /run.sh
|
||||||
|
|
||||||
|
RUN chmod a+x /run.sh
|
||||||
|
|
||||||
|
CMD /run.sh
|
3
examples/guestbook/redis-slave/run.sh
Executable file
3
examples/guestbook/redis-slave/run.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
redis-server --slaveof $SERVICE_HOST $REDISMASTER_SERVICE_PORT
|
Loading…
Reference in New Issue
Block a user