Skip to content

Commit

Permalink
add more
Browse files Browse the repository at this point in the history
Signed-off-by: Peng Xiao <[email protected]>
  • Loading branch information
xiaopeng163 committed Jan 30, 2018
1 parent 80696ea commit 136a7f4
Show file tree
Hide file tree
Showing 78 changed files with 2,386 additions and 24 deletions.
11 changes: 2 additions & 9 deletions chapter3/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ Vagrant.configure(2) do |config|
config.vm.network :private_network, ip: opts[:eth1]
end
end
config.vm.synced_folder ".", "/home/docker-host/"
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
curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh
sudo systemctl start docker
SHELL
config.vm.synced_folder "./labs", "/home/vagrant/labs"
config.vm.provision "shell", privileged: true, path: "./setup.sh"
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions chapter3/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#/bin/sh

# install some tools
sudo yum install -y git vim gcc glibc-static telnet bridge-utils net-tools

# install docker
curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh

# start docker service
sudo systemctl start docker

rm -rf get-docker.sh
19 changes: 5 additions & 14 deletions chapter4/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ boxes = [
:name => "docker-node1",
:eth1 => "192.168.205.10",
:mem => "1024",
:cpu => "1",
:port => "8888"
:cpu => "1"
},
{
:name => "docker-node2",
:eth1 => "192.168.205.11",
:mem => "1024",
:cpu => "1",
:port => "9999"
:cpu => "1"
}
]

Expand All @@ -27,7 +25,6 @@ Vagrant.configure(2) do |config|
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]
Expand All @@ -42,13 +39,7 @@ Vagrant.configure(2) do |config|
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 wget vim gcc glibc-static telnet
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
config.vm.synced_folder "./labs", "/home/vagrant/labs"
config.vm.provision "shell", privileged: true, path: "./setup.sh"

end
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions chapter4/labs/labs/docker-nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# this same shows how we can extend/change an existing official image from Docker Hub

FROM nginx:latest
# highly recommend you always pin versions for anything beyond dev/learn

WORKDIR /usr/share/nginx/html
# change working directory to root of nginx webhost
# using WORKDIR is prefered to using 'RUN cd /some/path'

COPY index.html index.html

# I don't have to specify EXPOSE or CMD because they're in my FROM
13 changes: 13 additions & 0 deletions chapter4/labs/labs/docker-nginx/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">

<title>hello</title>

</head>

<body>
<h1>Hello Docker! </h1>
</body>
</html>
8 changes: 8 additions & 0 deletions chapter4/labs/labs/flask-hello-world/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:2.7-alpine
LABEL maintainer="Peng Xiao<[email protected]>"
RUN pip install flask Flask-Script
COPY . /app/
WORKDIR /app
EXPOSE 5000
ENTRYPOINT [ "python", "manage.py" ]
CMD []
12 changes: 12 additions & 0 deletions chapter4/labs/labs/flask-hello-world/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return "hello dockeddr"

from flask_script import Manager

manager = Manager(app)

if __name__ == '__main__':
manager.run()
Empty file.
16 changes: 16 additions & 0 deletions chapter4/labs/labs/flask-skeleton/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[run]
source = skeleton
omit =
skeleton/tests/*
*/__init__.py

[report]
exclude_lines =
def __repr__
def __str__
def parse_args
pragma: no cover
raise NotImplementedError
if __name__ == .__main__.:

ignore_errors = True
91 changes: 91 additions & 0 deletions chapter4/labs/labs/flask-skeleton/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# dotenv
.env

# virtualenv
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject

*.sqlite
62 changes: 62 additions & 0 deletions chapter4/labs/labs/flask-skeleton/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
variables:
GIT_SSL_NO_VERIFY: "1"

stages:
- test
- build
- deploy

pep8:
stage: test
image: python:2.7
script:
- pip install tox
- tox -e pep8
tags:
- python27

unittest-py27:
stage: test
image: python:2.7
script:
- pip install tox
- tox -e py27
tags:
- python27

unittest-py34:
stage: test
image: python:3.4
script:
- pip install tox
- tox -e py34
tags:
- python34

sphnix:
stage: test
image: python:2.7
script:
- pip install tox
- tox -e docs
tags:
- python27

build:
stage: build
tags:
- shell
script:
- docker build -t skeleton .
only:
- master

deploy:
stage: deploy
tags:
- shell
script:
- scripts/deploy.sh
- export
only:
- master
28 changes: 28 additions & 0 deletions chapter4/labs/labs/flask-skeleton/.gitlab/issue_templates/Bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
### Summary

(Summarize the bug encountered concisely)

### Steps to reproduce

(How one can reproduce the issue - this is very important)

### Expected behavior

(What you should see instead)

### Actual behaviour

(What actually happens)

### Relevant logs and/or screenshots

(Paste any relevant logs - please use code blocks (```) to format console output,
logs, and code as it's very hard to read otherwise.)


### Possible fixes

(If you can, link to the line of code that might be responsible for the problem)


/label ~"Bug"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Feature Description


### Implementation


/label ~"Feature"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
**1. Explain what do you want to merge**

-
-

**2. Does this MR meet the acceptance criteria?**

- [ ] I have read [Contribution guidelines](https://as-gitlab.cisco.com/demo/skeleton/blob/master/CONTRIBUTING.md)
- [ ] I have run the command `tox` locally and get successful results.
- [ ] Branch has no merge conflicts with master (if you do - rebase it please)

**3. What are the relevant issue numbers?**


Thanks for your MR, you're awesome! :+1:
18 changes: 18 additions & 0 deletions chapter4/labs/labs/flask-skeleton/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Hacking Guide

## Code style

Step 1: Read http://www.python.org/dev/peps/pep-0008/

Step 2: Read http://www.python.org/dev/peps/pep-0008/ again

Step 3: Read on

## Running Tests

Run tox

```
$ cd skeleton
$ tox
```
8 changes: 8 additions & 0 deletions chapter4/labs/labs/flask-skeleton/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:2.7
LABEL maintainer="Peng Xiao<[email protected]>"

COPY . /skeleton
WORKDIR /skeleton
RUN pip install -r requirements.txt
EXPOSE 5000
ENTRYPOINT ["scripts/dev.sh"]
8 changes: 8 additions & 0 deletions chapter4/labs/labs/flask-skeleton/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2016 Michael Herman

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit 136a7f4

Please sign in to comment.