Skip to content
Snippets Groups Projects
Commit 51acbfe5 authored by nimrod's avatar nimrod
Browse files

- Added docker-compose.yml.

- Removed Makefile.
- Use Alpine Linux as base for app container.
- Create database in MySQL as part of startup.
- Added Vagrantfile (Ubuntu with Docker and Docker Compose).
- Pass settings to app as environment variables.
parent 2c3acc59
No related branches found
No related tags found
No related merge requests found
*~
~*
*.swp
*.swo
*.pyc
.DS_Store
__pycache__/
*.log
.vagrant/
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
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.
2.0.0
\ No newline at end of file
# -*- 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
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
......
File moved
#!/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'],
}
......
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment