Skip to content

Commit bc8b3bc

Browse files
committed
Worked in more server stuff for #28
1 parent 37b3614 commit bc8b3bc

File tree

2 files changed

+108
-90
lines changed

2 files changed

+108
-90
lines changed

docs/contribute/calaccess_website.rst

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ The ``.env`` is expected to contain a separate section for each environment, usi
6464
mysecretpassword=hotpockets
6565
6666
67-
By default, the source code will draw settings from a section name ``DEV``.To configure it to use ``PROD`` or any other set of variables,
67+
By default, the source code will draw settings from a section name ``DEV``. To configure it to use ``PROD`` or any other set of variables,
6868
set the ``CALACCESS_WEBSITE_ENV`` environment variable.
6969

7070
.. code-block:: bash
@@ -207,3 +207,110 @@ Finally, start the development server and visit `localhost:8000/admin/ <http://l
207207
$ python manage.py runserver
208208
209209
------------------
210+
211+
-----------------------------
212+
Preparing a production server
213+
-----------------------------
214+
215+
This sections will walk you through going further to deploy the :doc:`downloads website <apps/calaccess_downloads_sit>` on
216+
the Internet via Amazon Web Services. You will need to have completed the steps above.
217+
218+
Change your environment
219+
-----------------------
220+
221+
As described above, the source code will draw settings from a section of the `.env` file named ``DEV``.
222+
223+
To switch to configuring your project for a production environment, you should set the ``CALACCESS_WEBSITE_ENV`` environment
224+
variable to ``PROD``.
225+
226+
.. code-block:: bash
227+
228+
$ export CALACCESS_WEBSITE_ENV=PROD
229+
230+
If you are using virtualenv and virtualenvwrapper, you could add the above line of code to ``$VIRTUAL_ENV/bin/postactivate`` so that
231+
whenever you start the project's virtual environment, this variable will be exported automatically whenever you use ``workon`` to
232+
begin work.
233+
234+
---------------
235+
236+
Creating an RDS database
237+
------------------------
238+
239+
You will need to create a hosted database to store the data and keep tabs on the archive over time. Our recommended method
240+
for doing this is using `Amazon's Relational Database Service <https://aws.amazon.com/rds/>`_.
241+
242+
You can spin up a PostgreSQL server there using our prepackaged Fabric commands. You're only required to provide a
243+
name like ``download-website``:
244+
245+
.. code-block:: bash
246+
247+
$ fab createrds:download-website
248+
249+
Then, wait several minutes while the server is provisioned.
250+
251+
By default, the new database server will have 100 GB of disk space allocated on a t2.large RDS `class instance <https://aws.amazon.com/rds/postgresql/details/>`_. If need be, you can override these settings:
252+
253+
.. code-block:: bash
254+
255+
$ fab createrds:download-website,block_gb_size=80,instance_type=db.m4.large
256+
257+
The address for the RDS host will automatically be added to the configuration for your current environment, which is stored in ``.env``.
258+
If you already had an RDS host set for your current env, its address will be overwritten.
259+
260+
---------------
261+
262+
Create an EC2 Instance
263+
----------------------
264+
265+
Next you should create a new Ubuntu 14.04 server on `Amazon's Elastic Compute Cloud <https://aws.amazon.com/ec2/>`_ to host the Django project.
266+
267+
.. code-block:: bash
268+
269+
$ fab createec2
270+
271+
By default, the server will have 100 GB of disk space allocated on a c3.large `class instance <https://aws.amazon.com/ec2/instance-types/>`_. If need be, you can override these settings:
272+
273+
.. code-block:: bash
274+
275+
$ fab createec2:block_gb_size=80,instance_type=c3.xlarge
276+
277+
You can also override our default Amazon Machine Image (`AMI <http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html>`_):
278+
279+
.. code-block:: bash
280+
281+
$ fab createec2:ami=<some-other-ami-id>
282+
283+
As with creating an RDS instance, the address for your new EC2 instance will automatically be added to the configuration for your current environment, which is stored in ``.env``. If you already had an EC2 host set, its address will be overwritten.
284+
285+
---------------
286+
287+
Filling in .env for the second time
288+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289+
290+
Now you'll want to run our configuration command again, this time filling in the new details from your AWS account, database and server.
291+
You may want to create a new set of S3 buckets separate from your development buckets.
292+
293+
.. code-block:: bash
294+
295+
$ fab createconfig
296+
297+
Bootstrap the Django project
298+
----------------------------
299+
300+
Finally, you're ready to bootstrap the Django project on the Ubuntu server.
301+
302+
.. code-block:: bash
303+
304+
$ fab bootstrap
305+
306+
After connecting to your current EC2 instance, a framework called `Chef <https://www.chef.io/chef/>`_ and its dependencies, including Ruby,
307+
will be installed on the server. Chef is used to configure the server and install the downloads website's code.
308+
309+
The ``bootstrap`` task also sets up a crontab job to execute run as command every six hours that will automate the collection, extraction and processing of the daily CAL-ACCESS database exports.
310+
311+
--------------------------------------------
312+
313+
Wrapping up
314+
-----------
315+
316+
And that's it! You know have a live CAL-ACCESS archive running the cloud.

docs/contribute/calaccess_website/deployment-walkthru.rst

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)