Skip to content
This repository was archived by the owner on Aug 26, 2023. It is now read-only.

Commit 160745a

Browse files
Merge pull request #945 from dancerfly/docker-compose
Docker compose
2 parents c8befa3 + 0141176 commit 160745a

File tree

4 files changed

+80
-2
lines changed

4 files changed

+80
-2
lines changed

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:2
2+
ENV PYTHONUNBUFFERED 1
3+
RUN pip install pipenv
4+
RUN mkdir /django
5+
WORKDIR /django
6+
COPY Pipfile* /django/
7+
RUN pipenv install
8+
COPY . /code/
9+
ENTRYPOINT ["bin/docker-entrypoint.sh"]
10+
CMD ["./manage.py", "runserver", "0.0.0.0:8000"]

README.rst

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,49 @@ Naming
1111

1212
The name of this software is django-brambling. The name for use within the content of the application and for marketing purposes is Dancerfly.
1313

14-
Development
15-
=============
14+
Development Using Docker Compose
15+
================================
16+
17+
As of April 2020, Dancerfly experimentally allows you to use Docker Compose to spin up a development environment with one line. If you prefer to use the older method of relying on your system Python, skip below to "Development Using System Python."
18+
19+
Prerequisites
20+
-------------
21+
22+
These instructions assume you have the following software on your machine:
23+
24+
* `Docker Compose <https://docs.docker.com/compose/install/>`_
25+
26+
Installation instructions
27+
-------------------------
28+
29+
Here's a one-liner to get you going. This runs a database container using PostgreSQL and an application container with the Django application. It will run the necessary initial database migrations.
30+
31+
.. code:: bash
32+
33+
docker-compose up
34+
35+
Quick Tips
36+
----------
37+
38+
Use ``docker-compose exec`` to run commands on a currently running application container or ``docker-compose run`` to start a container and run a command:
39+
40+
.. code:: bash
41+
42+
docker-compose exec ./manage.py makemigrations
43+
docker-compose run pipenv install bleach
44+
45+
You can attach interactively to the Django process using this command:
46+
47+
.. code:: bash
48+
49+
docker attach (docker-compose ps -q django)
50+
51+
Learn more about Docker Compose in `the documentation <https://docs.docker.com/compose/>`_.
52+
53+
Development Using System Python
54+
===============================
55+
56+
Use these instructions if you'd rather not use Docker Compose.
1657

1758
Prerequisites
1859
-------------

bin/docker-entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
pipenv run ./manage.py migrate
5+
pipenv run $@

docker-compose.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: '3.7'
2+
services:
3+
postgresql:
4+
image: 'postgres:10.5-alpine'
5+
environment:
6+
POSTGRES_USER: dancerfly
7+
POSTGRES_PASSWORD: dancerflypassword
8+
POSTGRES_DB: dancerfly
9+
ports:
10+
- "127.0.0.1::5432"
11+
django:
12+
stdin_open: true
13+
tty: true
14+
ports:
15+
- "127.0.0.1:8000:8000"
16+
build: .
17+
environment:
18+
DATABASE_URL: postgres://dancerfly:dancerflypassword@postgresql/dancerfly
19+
volumes:
20+
- ./:/django
21+
depends_on:
22+
- postgresql

0 commit comments

Comments
 (0)