<commit_before># RSR Docker Development Environment

## System setup

1. Install `docker`
2. Install `docker-compose`

## Starting Up

1. Run `docker-compose up --build`

2. Visit [http://localhost/](http://localhost/)

## FAQ

##### Q: How do I migrate or get a Django shell?

You can `exec` commands on the web host. `docker-compose exec web python
manage.py shell` for example.


##### Q: How do I access a partnersite?

You will need to add an entry to your `/etc/hosts` file (or Windows equivalent),
and point `<partner_hostname>.localakvoapp.org` to `127.0.0.1` - for example,
add this line to be able to access the EUTF partner site:

```
127.0.0.1 eutf.localakvoapp.org
```

##### Q: How do I update the Python package dependencies?

To temporarily install additional packages in the docker machine, you can run
`docker-compose exec web pip install <package_name>`. Note that this
installation is temporary, and all changes are lost when `docker-compose down`
is run.

To install add a new dependency, add it to `requirements.txt`.


##### Q: I get a 502! Why?

Ensure that RSR is running. Chances are, a 502 means that no RSR app is running.

## Helpful notes

* When you are done developing, run `docker-compose down` to stop and remove
  containers, networks, images, and volumes.

* Run `docker-compose exec web /bin/bash` to get a shell on the docker web host.

* The `akvo-rsr` repository from your local machine is synced to the virtual
  machine, and the RSR application will restart when you make code changes.


## Useful scripts

There are a variety of useful scripts in `scripts/devhelpers`.
<commit_msg>Add instructions on how to restore DB from ElephantSQL<commit_after># RSR Docker Development Environment

## System setup

1. Install `docker`
2. Install `docker-compose`

## Starting Up

1. Run `docker-compose up --build`

2. Visit [http://localhost/](http://localhost/)

## FAQ

##### Q: How do I migrate or get a Django shell?

You can `exec` commands on the web host. `docker-compose exec web python
manage.py shell` for example.


##### Q: How do I access a partnersite?

You will need to add an entry to your `/etc/hosts` file (or Windows equivalent),
and point `<partner_hostname>.localakvoapp.org` to `127.0.0.1` - for example,
add this line to be able to access the EUTF partner site:

```
127.0.0.1 eutf.localakvoapp.org
```

##### Q: How do I update the Python package dependencies?

To temporarily install additional packages in the docker machine, you can run
`docker-compose exec web pip install <package_name>`. Note that this
installation is temporary, and all changes are lost when `docker-compose down`
is run.

To install add a new dependency, add it to `requirements.txt`.


##### Q: I get a 502! Why?

Ensure that RSR is running. Chances are, a 502 means that no RSR app is running.


##### Q: How do create a copy of the test/live DB for local testing?

See the instructions in the
[restore-elephantsql-dump-to-dev-env.sh](https://github.com/akvo/akvo-rsr/blob/develop/scripts/data/restore-elephantsql-dump-to-dev-env.sh#L3)
file.

## Helpful notes

* When you are done developing, run `docker-compose down` to stop and remove
  containers, networks, images, and volumes.

* Run `docker-compose exec web /bin/bash` to get a shell on the docker web host.

* The `akvo-rsr` repository from your local machine is synced to the virtual
  machine, and the RSR application will restart when you make code changes.

## Useful scripts

There are a variety of useful scripts in `scripts/devhelpers`.

{'fraction_non_alphanumeric': 0.09838846480067855, 'fraction_numerical': 0.01272264631043257, 'mean_word_length': 3.962131837307153, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1150722', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1058, 'n_words': 498}