You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/contribute/calaccess_website.rst
+108-1Lines changed: 108 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -64,7 +64,7 @@ The ``.env`` is expected to contain a separate section for each environment, usi
64
64
mysecretpassword=hotpockets
65
65
66
66
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,
68
68
set the ``CALACCESS_WEBSITE_ENV`` environment variable.
69
69
70
70
.. code-block:: bash
@@ -207,3 +207,110 @@ Finally, start the development server and visit `localhost:8000/admin/ <http://l
207
207
$ python manage.py runserver
208
208
209
209
------------------
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.
0 commit comments