Skip to content

Instantly share code, notes, and snippets.

@foxmask
Created November 21, 2016 21:25
Show Gist options
  • Save foxmask/84dfe256bb4d8b45011c159816ea85d8 to your computer and use it in GitHub Desktop.
Save foxmask/84dfe256bb4d8b45011c159816ea85d8 to your computer and use it in GitHub Desktop.
docker with cookiecutter-django
$ docker-machine create --driver virtualbox dev
Running pre-create checks...
Creating machine...
(dev) Copying /home/foxmask/.docker/machine/cache/boot2docker.iso to /home/foxmask/.docker/machine/machines/dev/boot2docker.iso...
(dev) Creating VirtualBox VM...
(dev) Creating SSH key...
(dev) Starting the VM...
(dev) Check network to re-create if needed...
(dev) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env dev
$ eval $(docker-machine env dev)
$ docker-compose -f dev.yml build
Building postgres
Step 1 : FROM postgres:9.5
9.5: Pulling from library/postgres
386a066cd84a: Pull complete
e6dd80b38d38: Pull complete
9cd706823821: Pull complete
40c17ac202a9: Pull complete
7380b383ba3d: Pull complete
538e418b46ce: Pull complete
94d2299e5dca: Pull complete
15cc322e0111: Pull complete
bfcccad2e159: Pull complete
323df6818afe: Pull complete
9908e2779cd7: Pull complete
Digest: sha256:c799bacde4426c0e57aaba7b2b90bd1d6ae61e5a7edbd6f36586ad2efea4444b
Status: Downloaded newer image for postgres:9.5
---> fc96933583ad
Step 2 : ADD backup.sh /usr/local/bin/backup
---> efdb56011d58
Removing intermediate container 5314bba3ab64
Step 3 : ADD restore.sh /usr/local/bin/restore
---> c2d4c4872154
Removing intermediate container 5de962786922
Step 4 : ADD list-backups.sh /usr/local/bin/list-backups
---> 87ff283877bf
Removing intermediate container e873edcec530
Step 5 : RUN chmod +x /usr/local/bin/restore
---> Running in aa9873913501
---> d9b19aad2264
Removing intermediate container aa9873913501
Step 6 : RUN chmod +x /usr/local/bin/list-backups
---> Running in 2af41ed3c65b
---> 4d8409911257
Removing intermediate container 2af41ed3c65b
Step 7 : RUN chmod +x /usr/local/bin/backup
---> Running in 6be2600ba7ce
---> 5a8f05fda8d5
Removing intermediate container 6be2600ba7ce
Successfully built 5a8f05fda8d5
Building django
Step 1 : FROM python:3.5
3.5: Pulling from library/python
386a066cd84a: Already exists
75ea84187083: Pull complete
88b459c9f665: Pull complete
1e3ee139a577: Pull complete
729baab2cba2: Pull complete
e7fb7abf1a53: Pull complete
dcf1c87e959f: Pull complete
Digest: sha256:f142b7cd6ae3538ba2c661999003099ef1e1e3fb9d79732170d82280871f93c2
Status: Downloaded newer image for python:3.5
---> 7045ed20ac61
Step 2 : ENV PYTHONUNBUFFERED 1
---> Running in 35f807557aae
---> 26b78b8efe80
Removing intermediate container 35f807557aae
Step 3 : COPY ./requirements /requirements
---> 1a5c65ee7796
Removing intermediate container fed40bdf8a3d
Step 4 : RUN pip install -r /requirements/local.txt
---> Running in 790378f66aab
Collecting wheel==0.29.0 (from -r /requirements/base.txt (line 5))
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
Collecting django-environ==0.4.1 (from -r /requirements/base.txt (line 11))
Downloading django_environ-0.4.1-py2.py3-none-any.whl
Collecting whitenoise==3.2.2 (from -r /requirements/base.txt (line 12))
Downloading whitenoise-3.2.2-py2.py3-none-any.whl
Collecting django-braces==1.10.0 (from -r /requirements/base.txt (line 16))
Downloading django_braces-1.10.0-py2.py3-none-any.whl
Collecting django-crispy-forms==1.6.1 (from -r /requirements/base.txt (line 17))
Downloading django_crispy_forms-1.6.1-py2.py3-none-any.whl (103kB)
Collecting django-model-utils==2.6 (from -r /requirements/base.txt (line 20))
Downloading django-model-utils-2.6.tar.gz
Collecting Pillow==3.4.2 (from -r /requirements/base.txt (line 23))
Downloading Pillow-3.4.2-cp35-cp35m-manylinux1_x86_64.whl (5.6MB)
Collecting django-allauth==0.28.0 (from -r /requirements/base.txt (line 27))
Downloading django-allauth-0.28.0.tar.gz (439kB)
Collecting psycopg2==2.6.2 (from -r /requirements/base.txt (line 31))
Downloading psycopg2-2.6.2.tar.gz (376kB)
Collecting awesome-slugify==1.6.5 (from -r /requirements/base.txt (line 34))
Downloading awesome-slugify-1.6.5.tar.gz
Collecting pytz==2016.7 (from -r /requirements/base.txt (line 37))
Downloading pytz-2016.7-py2.py3-none-any.whl (480kB)
Collecting django-redis==4.6.0 (from -r /requirements/base.txt (line 40))
Downloading django-redis-4.6.0.tar.gz (53kB)
Collecting redis>=2.10.5 (from -r /requirements/base.txt (line 41))
Downloading redis-2.10.5-py2.py3-none-any.whl (60kB)
Collecting arrow==0.8.0 (from -r /requirements/base.txt (line 48))
Downloading arrow-0.8.0.tar.gz (81kB)
Collecting Django==1.8.16 (from -r /requirements/base.txt (line 49))
Downloading Django-1.8.16-py2.py3-none-any.whl (6.2MB)
Collecting django-formtools==1.0 (from -r /requirements/base.txt (line 50))
Downloading django_formtools-1.0-py2.py3-none-any.whl (132kB)
Collecting django-js-reverse==0.7.2 (from -r /requirements/base.txt (line 51))
Downloading django_js_reverse-0.7.2-py2.py3-none-any.whl
Collecting evernote3 (from -r /requirements/base.txt (line 53))
Downloading evernote3-1.25.8.tar.gz (127kB)
Collecting feedparser==5.2.1 (from -r /requirements/base.txt (line 54))
Downloading feedparser-5.2.1.zip (1.2MB)
Collecting github3.py==1.0.0a4 (from -r /requirements/base.txt (line 55))
Downloading github3.py-1.0.0a4-py2.py3-none-any.whl (112kB)
Collecting pocket==0.3.6 (from -r /requirements/base.txt (line 56))
Downloading pocket-0.3.6.zip
Collecting py-trello==0.6.1 (from -r /requirements/base.txt (line 57))
Downloading py-trello-0.6.1.tar.gz
Collecting pytidylib==0.3.1 (from -r /requirements/base.txt (line 58))
Downloading pytidylib-0.3.1.tar.gz (87kB)
Collecting pypandoc==1.3.3 (from -r /requirements/base.txt (line 59))
Downloading pypandoc-1.3.3.tar.gz
Collecting requests-oauthlib==0.7.0 (from -r /requirements/base.txt (line 60))
Downloading requests_oauthlib-0.7.0-py2.py3-none-any.whl
Collecting twython==3.4.0 (from -r /requirements/base.txt (line 61))
Downloading twython-3.4.0.tar.gz
Collecting wallabag_api==1.1.0 (from -r /requirements/base.txt (line 62))
Downloading wallabag_api-1.1.0.tar.gz
Collecting flake8==3.0.4 (from -r /requirements/base.txt (line 63))
Downloading flake8-3.0.4-py2.py3-none-any.whl (64kB)
Collecting todoist-python==7.0.13 (from -r /requirements/base.txt (line 64))
Downloading todoist-python-7.0.13.tar.gz
Collecting pushbullet.py==0.10.0 (from -r /requirements/base.txt (line 65))
Downloading pushbullet.py-0.10.0-py2.py3-none-any.whl
Collecting instapush==0.1.2 (from -r /requirements/base.txt (line 66))
Downloading instapush-0.1.2.tar.gz
Collecting six (from django-environ==0.4.1->-r /requirements/base.txt (line 11))
Downloading six-1.10.0-py2.py3-none-any.whl
Collecting python3-openid>=3.0.8 (from django-allauth==0.28.0->-r /requirements/base.txt (line 27))
Downloading python3-openid-3.0.10.zip (365kB)
Collecting requests (from django-allauth==0.28.0->-r /requirements/base.txt (line 27))
Downloading requests-2.12.1-py2.py3-none-any.whl (574kB)
Collecting regex (from awesome-slugify==1.6.5->-r /requirements/base.txt (line 34))
Downloading regex-2016.11.21.tar.gz (599kB)
Collecting Unidecode<0.05,>=0.04.14 (from awesome-slugify==1.6.5->-r /requirements/base.txt (line 34))
Downloading Unidecode-0.04.19.tar.gz (204kB)
Collecting python-dateutil (from arrow==0.8.0->-r /requirements/base.txt (line 48))
Downloading python_dateutil-2.6.0-py2.py3-none-any.whl (194kB)
Collecting oauthlib (from evernote3->-r /requirements/base.txt (line 53))
Downloading oauthlib-2.0.0.tar.gz (122kB)
Collecting oauth2 (from evernote3->-r /requirements/base.txt (line 53))
Downloading oauth2-1.9.0.post1-py2.py3-none-any.whl
Collecting uritemplate.py>=0.2.0 (from github3.py==1.0.0a4->-r /requirements/base.txt (line 55))
Downloading uritemplate.py-3.0.2-py2.py3-none-any.whl
Requirement already satisfied: setuptools in /usr/local/lib/python3.5/site-packages (from pypandoc==1.3.3->-r /requirements/base.txt (line 59))
Requirement already satisfied: pip>=8.1.0 in /usr/local/lib/python3.5/site-packages (from pypandoc==1.3.3->-r /requirements/base.txt (line 59))
Collecting pyflakes!=1.2.0,!=1.2.1,!=1.2.2,<1.3.0,>=0.8.1 (from flake8==3.0.4->-r /requirements/base.txt (line 63))
Downloading pyflakes-1.2.3-py2.py3-none-any.whl (209kB)
Collecting pycodestyle<2.1.0,>=2.0.0 (from flake8==3.0.4->-r /requirements/base.txt (line 63))
Downloading pycodestyle-2.0.0-py2.py3-none-any.whl (42kB)
Collecting mccabe<0.6.0,>=0.5.0 (from flake8==3.0.4->-r /requirements/base.txt (line 63))
Downloading mccabe-0.5.2-py2.py3-none-any.whl
Collecting python-magic (from pushbullet.py==0.10.0->-r /requirements/base.txt (line 65))
Downloading python-magic-0.4.12.tar.gz
Collecting websocket-client (from pushbullet.py==0.10.0->-r /requirements/base.txt (line 65))
Downloading websocket_client-0.37.0.tar.gz (194kB)
Collecting defusedxml (from python3-openid>=3.0.8->django-allauth==0.28.0->-r /requirements/base.txt (line 27))
Downloading defusedxml-0.4.1.tar.gz (48kB)
Collecting httplib2 (from oauth2->evernote3->-r /requirements/base.txt (line 53))
Downloading httplib2-0.9.2.zip (210kB)
Collecting uritemplate>=2.0 (from uritemplate.py>=0.2.0->github3.py==1.0.0a4->-r /requirements/base.txt (line 55))
Downloading uritemplate-3.0.0-py2.py3-none-any.whl
Installing collected packages: wheel, six, Django, django-environ, whitenoise, django-braces, django-crispy-forms, django-model-utils, Pillow, defusedxml, python3-openid, oauthlib, requests, requests-oauthlib, django-allauth, psycopg2, regex, Unidecode, awesome-slugify, pytz, redis, django-redis, python-dateutil, arrow, django-formtools, django-js-reverse, httplib2, oauth2, evernote3, feedparser, uritemplate, uritemplate.py, github3.py, pocket, py-trello, pytidylib, pypandoc, twython, wallabag-api, pyflakes, pycodestyle, mccabe, flake8, todoist-python, python-magic, websocket-client, pushbullet.py, instapush
Running setup.py install for django-model-utils: started
Running setup.py install for django-model-utils: finished with status 'done'
Running setup.py install for defusedxml: started
Running setup.py install for defusedxml: finished with status 'done'
Running setup.py install for python3-openid: started
Running setup.py install for python3-openid: finished with status 'done'
Running setup.py install for oauthlib: started
Running setup.py install for oauthlib: finished with status 'done'
Running setup.py install for django-allauth: started
Running setup.py install for django-allauth: finished with status 'done'
Running setup.py install for psycopg2: started
Running setup.py install for psycopg2: finished with status 'done'
Running setup.py install for regex: started
Running setup.py install for regex: finished with status 'done'
Running setup.py install for Unidecode: started
Running setup.py install for Unidecode: finished with status 'done'
Running setup.py install for awesome-slugify: started
Running setup.py install for awesome-slugify: finished with status 'done'
Running setup.py install for django-redis: started
Running setup.py install for django-redis: finished with status 'done'
Running setup.py install for arrow: started
Running setup.py install for arrow: finished with status 'done'
Running setup.py install for httplib2: started
Running setup.py install for httplib2: finished with status 'done'
Running setup.py install for evernote3: started
Running setup.py install for evernote3: finished with status 'done'
Running setup.py install for feedparser: started
Running setup.py install for feedparser: finished with status 'done'
Running setup.py install for pocket: started
Running setup.py install for pocket: finished with status 'done'
Running setup.py install for py-trello: started
Running setup.py install for py-trello: finished with status 'done'
Running setup.py install for pytidylib: started
Running setup.py install for pytidylib: finished with status 'done'
Running setup.py install for pypandoc: started
Running setup.py install for pypandoc: finished with status 'done'
Running setup.py install for twython: started
Running setup.py install for twython: finished with status 'done'
Running setup.py install for wallabag-api: started
Running setup.py install for wallabag-api: finished with status 'done'
Running setup.py install for todoist-python: started
Running setup.py install for todoist-python: finished with status 'done'
Running setup.py install for python-magic: started
Running setup.py install for python-magic: finished with status 'done'
Running setup.py install for websocket-client: started
Running setup.py install for websocket-client: finished with status 'done'
Running setup.py install for instapush: started
Running setup.py install for instapush: finished with status 'done'
Successfully installed Django-1.8.16 Pillow-3.4.2 Unidecode-0.4.19 arrow-0.8.0 awesome-slugify-1.6.5 defusedxml-0.4.1 django-allauth-0.28.0 django-braces-1.10.0 django-crispy-forms-1.6.1 django-environ-0.4.1 django-formtools-1.0 django-js-reverse-0.7.2 django-model-utils-2.6 django-redis-4.6.0 evernote3-1.25.0 feedparser-5.2.1 flake8-3.0.4 github3.py-1.0.0a4 httplib2-0.9.2 instapush-0.1.2 mccabe-0.5.2 oauth2-1.9.0.post1 oauthlib-2.0.0 pocket-0.3.6 psycopg2-2.6.2 pushbullet.py-0.10.0 py-trello-0.6.1 pycodestyle-2.0.0 pyflakes-1.2.3 pypandoc-1.3.3 python-dateutil-2.6.0 python-magic-0.4.12 python3-openid-3.0.10 pytidylib-0.3.1 pytz-2016.7 redis-2.10.5 regex-2016.11.21 requests-2.12.1 requests-oauthlib-0.7.0 six-1.10.0 todoist-python-7.0.13 twython-3.4.0 uritemplate-3.0.0 uritemplate.py-3.0.2 wallabag-api-1.1.0 websocket-client-0.37.0 wheel-0.29.0 whitenoise-3.2.2
---> 3b2dea0001d3
Removing intermediate container 790378f66aab
Step 5 : COPY ./compose/django/entrypoint.sh /entrypoint.sh
---> af6a0337dcca
Removing intermediate container 17fd092eb82a
Step 6 : RUN sed -i 's/\r//' /entrypoint.sh
---> Running in c6213ae5d4dc
---> ccb2fb87e4b7
Removing intermediate container c6213ae5d4dc
Step 7 : RUN chmod +x /entrypoint.sh
---> Running in 5c92d33030f0
---> 9c0c173f7ea6
Removing intermediate container 5c92d33030f0
Step 8 : COPY ./compose/django/start-dev.sh /start-dev.sh
---> fb025b54ae42
Removing intermediate container eae136000df2
Step 9 : RUN sed -i 's/\r//' /start-dev.sh
---> Running in f71654188caa
---> f077da103a38
Removing intermediate container f71654188caa
Step 10 : RUN chmod +x /start-dev.sh
---> Running in 284398f976d3
---> bb22e9487684
Removing intermediate container 284398f976d3
Step 11 : WORKDIR /app
---> Running in e5230925fbce
---> f2ae382f18f2
Removing intermediate container e5230925fbce
Step 12 : ENTRYPOINT /entrypoint.sh
---> Running in 184b012c25e1
---> d81aa7e286fd
Removing intermediate container 184b012c25e1
Successfully built d81aa7e286fd
$ docker-compose -f dev.yml up -d
Creating network "triggerhappy_default" with the default driver
Creating volume "triggerhappy_postgres_data_dev" with default driver
Creating volume "triggerhappy_postgres_backup_dev" with default driver
Creating triggerhappy_postgres_1
Creating triggerhappy_django_1
$ docker-compose -f dev.yml run django python manage.py makemigrations
Postgres is up - continuing...
python: can't open file 'manage.py': [Errno 2] No such file or directory
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
eb9210f46556 triggerhappy_postgres "/docker-entrypoint.s" About a minute ago Up About a minute 5432/tcp
triggerhappy_postgres_1
$ docker-compose -f dev.yml run django ls -la
Postgres is up - continuing...
total 4
drwxr-xr-x 2 root root 40 Nov 21 21:20 .
drwxr-xr-x 60 root root 4096 Nov 21 21:22 ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment