提交 7f60b32b 编写于 作者: P Pike

get containerID fron php server

上级 4473c456
# Using a compact OS
FROM alpine:latest
FROM php:5-zts-alpine
MAINTAINER Golfen Guo <golfen.guo@daocloud.io>
MAINTAINER Golfen Guo <golfen.guo@daocloud.io>
# Install and configure Nginx
RUN apk --update add nginx
RUN sed -i "s#root html;#root /usr/share/nginx/html;#g" /etc/nginx/nginx.conf
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
# Add 2048 stuff into Nginx server
COPY . /usr/share/nginx/html
EXPOSE 80
# Start Nginx and keep it from running background
CMD ["nginx", "-g", "pid /tmp/nginx.pid; daemon off;"]
# Start Nginx and keep it running background and start php
CMD nginx -g "pid /tmp/nginx.pid; daemon on;" && php -S 0.0.0.0:8888 /usr/share/nginx/html/hostname.php
<?php
header('Access-Control-Allow-Origin: *');
if ("/" == $_SERVER["REQUEST_URI"]) {
echo gethostname();
}
?>
......@@ -2,3 +2,20 @@
window.requestAnimationFrame(function () {
new GameManager(4, KeyboardInputManager, HTMLActuator, LocalStorageManager);
});
function httpGet(url) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", url, false);
xmlHttp.send(null);
return xmlHttp.responseText;
}
function setContainerID() {
var hostname = httpGet("http://" + window.location.hostname + ":8888");
var container = document.getElementsByClassName("container")[0];
var tmp = document.createElement('div');
tmp.innerHTML = '<p style="position:absolute;left:60px;top:100px;">ContainerID: ' + hostname + "</p>";
container.insertBefore(tmp, container.children[0]);
}
setContainerID();
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册