Skip to content

Commit

Permalink
fixed volume-init-example
Browse files Browse the repository at this point in the history
  • Loading branch information
sgeisbacher committed Feb 18, 2017
1 parent be13495 commit c46363d
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ vendor/
!vendor/vendor.json
coverage.out
docker-compose.yml
examples/volume/data/
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/volume/container-juggler.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
templateFolderPath: ./examples/volume/templates/
templateFolderPath: ./templates/
scenarios:
all:
- frontend
Expand All @@ -12,5 +12,5 @@ scenarios:
- db
volume-init:
- name: app-data-dir
source: ./examples/volume/templates/appdata.zip
source: https://github.com/sgeisbacher/container-juggler/raw/master/examples/appdata.zip
target: ./data/app
4 changes: 4 additions & 0 deletions examples/volume/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
COPY www /usr/share/nginx/html
RUN chown nginx.nginx /usr/share/nginx/html/ -R
41 changes: 41 additions & 0 deletions examples/volume/frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
keepalive_timeout 65;

server {
listen 80 default_server;
listen [::]:80 default_server;

root /usr/share/nginx/html;

index index.html index.htm index.nginx-debian.html;

server_name _;

location /rest/ {
proxy_pass http://app:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}


location / {
try_files $uri $uri/ /index.html;
}

}

}

55 changes: 55 additions & 0 deletions examples/volume/frontend/www/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<html>
<head>
<title>Basic example</title>
<style>
button {
margin-top: 10px;
font-size: 25px;
}
</style>
</head>
<body>
<h1>/data/</h1>
<div id="data">
</div>
<div>
<button id="addData">add data</button>
</div>

</body>
<script>
function fetchData() {
fetch('/rest/data/')
.then(function(response) {
return response.json();
})
.then(function(json) {
var content = json.map((item) => {
return `id: ${item._id}, data: ${item.data}`;
}).join("<br/>");
document.querySelector('#data').innerHTML = content;
})
.catch(function(err) {
window.alert(err);
});
}
fetchData();
document.querySelector('#addData').addEventListener('click', function() {
fetch('/rest/data/', {
method: 'POST',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
body: JSON.stringify({
data: 'some new data'
})
}).then(function() {
fetchData();
})
.catch(function(err) {
window.alert(err);
});
});
</script>
</html>
2 changes: 1 addition & 1 deletion examples/volume/templates/app.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build: ./examples/volume/templates/app
build: ./app
links:
- db
ports:
Expand Down
2 changes: 1 addition & 1 deletion examples/volume/templates/frontend.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build: ./examples/basic/templates/frontend
build: ./frontend
links:
- app
ports:
Expand Down

0 comments on commit c46363d

Please sign in to comment.