Requirements
------------
-For the purpose of this guide, we will assume an **Ubuntu 18.04** host:
+For the purpose of this guide, we will assume an **Ubuntu 20.04** host:
commands, package names and/or package versions will likely change if using a
different distro or release. Similarly, usage of different package versions to
the ones suggested may require slightly different configuration.
.. code-block:: shell
$ tar -xvzf v3.0.0.tar.gz
- $ sudo mv v3.0.0 /opt/patchwork
+ $ sudo mv patchwork-3.0.0 /opt/patchwork
.. important::
- ``DATABASE_HOST``
- ``DATABASE_PORT``
-Configure the ``DATABASE`` setting in ``production.py`` accordingly.
+Export these environment variables or configure the ``DATABASE`` setting in
+``production.py`` accordingly.
Static Files
^^^^^^^^^^^^
$ sudo mkdir -p /var/www/patchwork
-You can configure this by configuring the ``STATIC_ROOT`` setting in
-``production.py``.
+Export the ``STATIC_ROOT`` environment variable or configure the
+``STATIC_ROOT`` setting in ``production.py``.
.. code-block:: python
.. code-block:: python
import string
- try:
- import secrets
- except ImportError: # Python < 3.6
- import random
- secrets = random.SystemRandom()
+ import secrets
chars = string.ascii_letters + string.digits + string.punctuation
print("".join([secrets.choice(chars) for i in range(50)]))
-Once again, store this in ``production.py``.
+Export the ``DJANGO_STATIC_KEY`` environment variable or configure the
+``STATIC_KEY`` setting in ``production.py``.
Other Options
^^^^^^^^^^^^^
There are many other settings that may be configured, many of which are
described in :doc:`configuration`.
-* ``SECRET_KEY``
* ``ADMINS``
* ``TIME_ZONE``
* ``LANGUAGE_CODE``
$ sudo -u www-data python3 manage.py check
+.. note::
+
+ If you've been using environment variables to configure your deployment,
+ you must pass the ``--preserve-env`` option for each attribute or pass the
+ environments as part of the command:
+
+ .. code-block:: shell
+
+ $ sudo -u www-data \
+ --preserve-env=DATABASE_NAME \
+ --preserve-env=DATABASE_USER \
+ --preserve-env=DATABASE_PASS \
+ --preserve-env=DATABASE_HOST \
+ --preserve-env=DATABASE_PORT \
+ --preserve-env=STATIC_ROOT \
+ --preserve-env=DJANGO_SECRET_KEY \
+ python3 manage.py check
+
We should also take this opportunity to both configure the database and static
files:
We created the ``/etc/uwsgi`` directory above because we're going to run
*uWSGI* in `emperor mode`__. This has benefits for multi-app deployments.
+.. note::
+
+ If you're using environment variables for configuration, you will need to
+ edit the ``patchwork.ini`` file created above to include these using the
+ ``env = VAR=VALUE`` syntax.
+
__ https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html
Configure Patchwork