diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4a69ea41b4d84900ba4fea53ce0cc3a87cce8a6e --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*~ +~* +*.swp +*.swo +*.pyc +.DS_Store +__pycache__/ +*.log +.vagrant/ diff --git a/Makefile b/Makefile deleted file mode 100644 index baf8d23e40a0020485b19cd48770752148d2da05..0000000000000000000000000000000000000000 --- a/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -build: - docker build --tag intro . - -run: - docker run --publish 5000:5000 intro - -pull: - docker pull mysql:5.5 - -rundb: - docker run --detach --publish-all --env MYSQL_ROOT_PASSWORD=qwerty123 --name mysql mysql:5.5 - -createdb: - echo 'create database db' | mysql -uroot -pqwerty123 --protocol tcp --port $$MYSQL_PORT - -run-linked: - docker run --link mysql:mysql --publish 5000:5000 intro diff --git a/README.rst b/README.rst index e6d24692a5f4eb6f8aec53a5d7945e6bd3e59b7f..b65a6b5b9fd2e81ccd7f0e51bbce8700360b68c6 100644 --- a/README.rst +++ b/README.rst @@ -1,17 +1,9 @@ docker-intro -============ -A hands-on introduction to Docker. - -Requirements: +############ -- Docker - -- Make +A hands-on introduction to Docker. -Commands: :: +TODO +---- - make build - make run - make pull - make startdb - make run-linked +- Presentation. diff --git a/VERSION b/VERSION new file mode 100644 index 0000000000000000000000000000000000000000..359a5b952d49f3592571e2af081510656029298e --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +2.0.0 \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000000000000000000000000000000000000..5ddd671a390d08c0fa68b382bea9e64f6ce48f9b --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,18 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure(2) do |config| + config.vm.box = "ubuntu/trusty64" + config.vm.provision "shell", inline: <<-SHELL + sudo apt-get update + sudo apt-get install -yf git python-dev python-pip apt-transport-https ca-certificates + sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D + echo 'deb https://apt.dockerproject.org/repo ubuntu-trusty main' | sudo tee /etc/apt/sources.list.d/docker.list + sudo apt-get update + sudo apt-get install -yf docker-engine + sudo pip install docker-compose + sudo sed -i 's/DEFAULT_FORWARD_POLICY=.*/DEFAULT_FORWARD_POLICY="ACCEPT"/g' /etc/default/ufw + sudo service ufw restart + sudo usermod -aG docker vagrant + SHELL +end diff --git a/Dockerfile b/app/Dockerfile similarity index 62% rename from Dockerfile rename to app/Dockerfile index 54d423027463100ffae62148a622ce5a66c9a1be..4a452bb8128a6546ac53a12fa031d7237e6ef244 100644 --- a/Dockerfile +++ b/app/Dockerfile @@ -1,6 +1,6 @@ -FROM debian:latest +FROM alpine MAINTAINER Nimrod Adar <nimrod@shore.co.il> -RUN apt-get update && apt-get install -yf python-dev python-pip python-mysqldb +RUN apk add --update python py-pip py-mysqldb mysql-client && rm -rf /var/cache/apk/* COPY ./ /opt/docker-intro/ WORKDIR /opt/docker-intro RUN pip install -r requirements.txt diff --git a/requirements.txt b/app/requirements.txt similarity index 100% rename from requirements.txt rename to app/requirements.txt diff --git a/trivial.py b/app/trivial.py similarity index 93% rename from trivial.py rename to app/trivial.py index 98d9bd06241740fc377804a07a1b2a3e4da114d4..17ba5220509734fc5d0b6a87d992b6ba7cd3028b 100755 --- a/trivial.py +++ b/app/trivial.py @@ -1,5 +1,6 @@ #!/usr/bin/env python ''' Trivial Eve-SQLAlchemy example. ''' +from os import environ # SQLAlchemy Imports from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import column_property @@ -35,8 +36,8 @@ class People(Base): registerSchema('people')(People) SETTINGS = { - 'DEBUG': True, - 'SQLALCHEMY_DATABASE_URI': 'mysql://root:qwerty123@mysql/db', + 'DEBUG': environ['DEBUG'], + 'SQLALCHEMY_DATABASE_URI': environ['DATABASE_URI'], 'DOMAIN': { 'people': People._eve_schema['people'], } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..b548c7c2f05b211119c5328c9929aef2ecce9f92 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +app: + build: app + ports: + - 5000:5000 + environment: + DATABASE_URI: mysql://root:qwerty123@db/app + DEBUG: 'True' + volumes: + - ./app:/opt/docker-intro + links: + - db +db: + image: mysql + environment: + MYSQL_ROOT_PASSWORD: qwerty123 + MYSQL_DATABASE: app