Skip to content

Commit

Permalink
upgrade docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed Feb 22, 2018
1 parent b44544c commit c47222b
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 140 deletions.
104 changes: 104 additions & 0 deletions docs/reference/docker.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
=======================
Deployment using Docker
=======================

By using Docker_ in combination with docker-compose_, the deployment of a **django-SHOP**
installation becomes really simple. We make use of this in the demos, but these examples
are intended to run on a local host, hence we can use the internal webserver provided by
uWSGI_. In a productive environment, we usually want to use a specialized webserver, such
as NGiNX_. This allows us to dispatch multiple server names on the same IPn address and to
terminate https-connections.


Run django-SHOP behind NGiNX
============================

In a production environment, usually you run these, and probably other containers behind a single
NGiNX instance. Additionally, since our customers normally do provide their user credentials and
other sensitive information, such as credit card numbers, we should ensure that our connection is
secured by https.

To do so, we run a separate composition of two Docker containers using this configuration:

.. code-block:: yaml
:caption: nginx-compose.yml
version: '2.0'
services:
nginx-proxy:
restart: always
image: jwilder/nginx-proxy:latest
ports:
- '80:80'
- '443:443'
volumes:
- '/var/run/docker.sock:/tmp/docker.sock:ro'
- '/etc/nginx/vhost.d'
- '/usr/share/nginx/html'
- '/etc/nginx/certs'
networks:
- nginx-proxy
letsencrypt-nginx-proxy-companion:
image: jrcs/letsencrypt-nginx-proxy-companion
volumes:
- '/var/run/docker.sock:/var/run/docker.sock:ro'
volumes_from:
- 'nginx-proxy'
networks:
nginx-proxy:
external: true
Now we build and run the webserver.

.. code-block:: bash
$ docker-compose -f nginx-compose.yml up --build -d
This spawns up two running Docker containers, where ``nginx-proxy`` is the actual webserver and
``letsencrypt-nginx-proxy-companion`` just manages the SSL certificates using the Let's Encrypt
certification authority. Note that you must point at least one DNS entry onto the IP address of
this host.


Run the django-SHOP container composition
=========================================

Each instance of a django-SHOP

Next edit ``docker-compose.yml``, locate the section ``wsgiapps`` and add 2 environment
variables and an additional network configuration:

.. code-block:: yaml
:caption: docker-compose.yml
wsgiapp:
...
environment:
...
- VIRTUAL_HOST=djangoshop
- VIRTUAL_PROTO=uwsgi
...
networks:
...
- nginx-proxy
expose:
- 9009
...
networks:
...
- nginx-proxy:
external: true
Re-create and run the Docker containers using ``docker-compose up -d``.

Edit ``/etc/hosts`` and let ``djangoshop`` point onto 192.168.100.99 (the IP
address may vary depending on your Docker machine settings).

Point a browser onto http://djangoshop/ . It now is possible to browse the container through
NGiNX as proxy.


.. _uWSGI: http://uwsgi.readthedocs.org/
2 changes: 1 addition & 1 deletion docs/tutorial/catalog-views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ The ``AddToCartSerializer``

Rather than using the detail serializer, the business logic for adding a product to the cart has
been moved into a specialized serializer. This is because **django-SHOP** can not presuppose that
products are added to the cart only from within the detail view[#add2cart]_. We also need a way to
products are added to the cart only from within the detail view [#add2cart]_. We also need a way to
add more than one product variant to the cart from each products detail page.

For this purpose **django-SHOP** is shipped with an ``AddToCartSerializer``. It can be overridden
Expand Down
Loading

0 comments on commit c47222b

Please sign in to comment.