Skip to content
This repository has been archived by the owner on Jan 31, 2018. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemarsden committed Nov 8, 2016
0 parents commit d51de64
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM tutum/apache-php
ADD *.php /app
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '2'
services:
web:
build: .
ports:
- "80:80"
volumes:
- .:/code
depends_on:
- postgres
postgres:
image: postgres
39 changes: 39 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<html>
<head>
<title>KubeCon keynote demo</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,500,700,400italic|Material+Icons" rel="stylesheet">
<style>
* { font-family: Roboto; }
</style>
</head>
<body>
<?php
$color = "red";
if($color == "red") {
$hex = "#F44336";
} else if($color == "green") {
$hex = "#4CAF50";
}
?>
<span style="background-color: #F44336; color:white;">Hello, world! I am the red version, running in container <?=`hostname`?> in <?=json_decode(file_get_contents("http://freegeoip.net/json"))["country_name"];?>.</span>
<form action="index.php">
<p>Word: <input type="text"></p>
<input type="submit">
</form>
<?php
$dbconn = pg_connect("host=postgres dbname=words user=root password=password");
if(!$dbconn) {
?><p>No database connection.</p><?
}
if($_POST["text"]) {
pg_query("insert into hello (name) values (".pg_escape_literal($_POST["text"]).")");
}
$result = pg_query("select word from hello");
?><ul><?
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
?><li><?=$line?></li><?
}
?></ul><?
?>
</body>
</html>
3 changes: 3 additions & 0 deletions setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
$dbconn = pg_connect("host=pgsql dbname=words user=root password=password");
pg_query("create table hello (word text)");

0 comments on commit d51de64

Please sign in to comment.