<commit_before>Docker Dev Notes
================

Using Docker in development helps produce a consistent environment that's close
to the real production site.

Setup
=====

This documentation is going to assume you have Docker installed and configured
already. See the [Docker documentation][docker-docs] for help.

[docker-docs]: https://docs.docker.com/

* To launch the containers:

  `docker-compose up`

  Running `docker-compose up` from the root directory starts the database and
  web server. The frontend build step (see [frontend docs](../docs/frontend.md))
  builds the static files on the host machine. The host machine and web server
  container share a volume.

* To populate the database with sample data:

  `docker exec viewer_server_1 ./manage.py loaddata fixtures/sample.json`

Testing
=======

Syntax & unit tests must pass for Pull Requests to be accepted on GitHub.

    * To run server tests:

      `docker-compose run server test backend`

This will run both the Django tests and the linting tests.


Tips & Tricks
=============

* To shell into the server container:

  `docker exec -ti viewer_server_1 sh`

  This is necessary for running Django commands, among other things.

* If you change `requirements.txt` to add dependencies for Django, you must rebuild `server`:

  `docker-compose build server`

* Sometimes the database container hasn't fully started when the Django container wants to connect to it. If this happens:

  * `docker ps` to get the name of the Django container (something like `viewer_server_1`)
  * `docker restart viewer_server_1` to restart the Django container<commit_msg>Revert the accidental changes to docker naming<commit_after>Docker Dev Notes
================

Using Docker in development helps produce a consistent environment that's close
to the real production site.

Setup
=====

This documentation is going to assume you have Docker installed and configured
already. See the [Docker documentation][docker-docs] for help.

[docker-docs]: https://docs.docker.com/

* To launch the containers:

  `docker-compose up`

  Running `docker-compose up` from the root directory starts the database and
  web server. The frontend build step (see [frontend docs](../docs/frontend.md))
  builds the static files on the host machine. The host machine and web server
  container share a volume.

* To populate the database with sample data:

  `docker exec distributionviewer_server_1 ./manage.py loaddata fixtures/sample.json`

Testing
=======

Syntax & unit tests must pass for Pull Requests to be accepted on GitHub.

    * To run server tests:

      `docker-compose run server test backend`

This will run both the Django tests and the linting tests.


Tips & Tricks
=============

* To shell into the server container:

  `docker-compose run server sh`

  This is necessary for running Django commands, among other things.

* If you change `requirements.txt` to add dependencies for Django, you must rebuild `server`:

  `docker-compose build server`

* Sometimes the database container hasn't fully started when the Django container wants to connect to it. If this happens:

  * `docker ps` to get the name of the Django container (something like `distributionviewer_server_1`)
  * `docker restart distributionviewer_server_1` to restart the Django container
{'fraction_non_alphanumeric': 0.08139885438649382, 'fraction_numerical': 0.0021103406692794696, 'mean_word_length': 4.266666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2917788', 'n_tokens_mistral': 926, 'n_tokens_neox': 834, 'n_words': 426}