-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Peng Xiao <[email protected]>
- Loading branch information
1 parent
e7a68f9
commit db04447
Showing
5 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
Vagrant.require_version ">= 1.6.0" | ||
|
||
boxes = [ | ||
{ | ||
:name => "docker-host", | ||
:eth1 => "192.168.205.10", | ||
:mem => "1024", | ||
:cpu => "1" | ||
} | ||
] | ||
|
||
Vagrant.configure(2) do |config| | ||
|
||
config.vm.box = "centos/7" | ||
config.vm.synced_folder ".", "/home/docker-host/" | ||
boxes.each do |opts| | ||
config.vm.define opts[:name] do |config| | ||
config.vm.hostname = opts[:name] | ||
config.vm.provider "vmware_fusion" do |v| | ||
v.vmx["memsize"] = opts[:mem] | ||
v.vmx["numvcpus"] = opts[:cpu] | ||
end | ||
config.vm.provider "virtualbox" do |v| | ||
v.customize ["modifyvm", :id, "--memory", opts[:mem]] | ||
v.customize ["modifyvm", :id, "--cpus", opts[:cpu]] | ||
end | ||
config.vm.network :private_network, ip: opts[:eth1] | ||
end | ||
end | ||
config.vm.provision "shell", inline: <<-SHELL | ||
# https://docs.docker.com/engine/installation/linux/docker-ce/centos/ | ||
# https://github.com/docker/docker-install | ||
sudo yum install -y git vim gcc glibc-static telnet | ||
git clone sudo yum install -y git vim gcc glibc-static telnet | ||
curl -fsSL get.docker.com -o get-docker.sh | ||
sh get-docker.sh | ||
sudo systemctl start docker | ||
SHELL | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
Vagrant.require_version ">= 1.6.0" | ||
|
||
boxes = [ | ||
{ | ||
:name => "docker-node1", | ||
:eth1 => "192.168.205.10", | ||
:mem => "1024", | ||
:cpu => "1", | ||
:port => "8888" | ||
}, | ||
{ | ||
:name => "docker-node2", | ||
:eth1 => "192.168.205.11", | ||
:mem => "1024", | ||
:cpu => "1", | ||
:port => "9999" | ||
} | ||
] | ||
|
||
Vagrant.configure(2) do |config| | ||
|
||
config.vm.box = "centos/7" | ||
|
||
boxes.each do |opts| | ||
config.vm.define opts[:name] do |config| | ||
config.vm.hostname = opts[:name] | ||
config.vm.network "forwarded_port", guest: 80, host: opts[:port] | ||
config.vm.provider "vmware_fusion" do |v| | ||
v.vmx["memsize"] = opts[:mem] | ||
v.vmx["numvcpus"] = opts[:cpu] | ||
end | ||
|
||
config.vm.provider "virtualbox" do |v| | ||
v.customize ["modifyvm", :id, "--memory", opts[:mem]] | ||
v.customize ["modifyvm", :id, "--cpus", opts[:cpu]] | ||
end | ||
|
||
config.vm.network :private_network, ip: opts[:eth1] | ||
end | ||
end | ||
|
||
config.vm.provision "shell", inline: <<-SHELL | ||
# https://docs.docker.com/engine/installation/linux/docker-ce/centos/ | ||
# https://github.com/docker/docker-install | ||
sudo yum install -y git vim gcc glibc-static telnet | ||
git clone sudo yum install -y git vim gcc glibc-static telnet | ||
curl -fsSL get.docker.com -o get-docker.sh | ||
sh get-docker.sh | ||
sudo systemctl start docker | ||
SHELL | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM python:2.7 | ||
LABEL maintaner="Peng Xiao [email protected]" | ||
COPY . /app | ||
WORKDIR /app | ||
RUN pip install flask redis | ||
EXPOSE 5000 | ||
CMD [ "python", "app.py" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from flask import Flask | ||
from redis import Redis | ||
import os | ||
import socket | ||
|
||
app = Flask(__name__) | ||
redis = Redis(host=os.environ.get('REDIS_HOST', '127.0.0.1'), port=6379) | ||
|
||
|
||
@app.route('/') | ||
def hello(): | ||
redis.incr('hits') | ||
return 'Hello Container World! I have been seen %s times and my hostname is %s.\n' % (redis.get('hits'),socket.gethostname()) | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(host="0.0.0.0", port=5000, debug=True) |