Skip to content

Commit

Permalink
Readme update (#2)
Browse files Browse the repository at this point in the history
* README.md updated.
local_settings.py changed.
docker-compose.cloud.yml added for deploy

* add to deploy

* add dump_small.tar.gz to gitignore

* README.md update - for copy the local_settings file to the machine.
  • Loading branch information
idanelbaz authored and shacharmo committed Jan 2, 2020
1 parent 55d795f commit 3aa3016
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Sefaria-Project
dump
/dump_small.tar.gz
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
# Sefaria-Docker
These scripts create three containers tied together with docker-compose. One is a vanilla Redis install, one is a mongo install built with the latest Sefaria data, and the third is a Python/Django/Node server running the latest Sefaria code.
These scripts create three containers tied together with docker-compose.
One is a vanilla Redis install, one is a mongo install built with the latest Sefaria data,
and the third is a Python/Django/Node server running the latest Sefaria web code.

The `./build` script will fetch the latest data and built the containers.
The `./build` script will fetch the latest data and built the containers.
The `./run` script will bring up the containers and provision the local Sefaria web client on `0.0.0.0:8000`.


# Quick Start
* Install Docker.
* On Mac, this works well - https://store.docker.com/editions/community/docker-ce-desktop-mac
* Clone this repo.
* `./build`
* `./run`
* Browse to `http://0.0.0.0:8000`.
* Download https://storage.googleapis.com/sefaria-mongo-backup/dump_small.tar.gz to local directory.
* `./build`.
* `./run`.
* Browse to `http://0.0.0.0:8000` / `localhost:8000`.
* To check the containers status and ports type - `docker ps`.

# API
* To fetch data from the Sefaria API browse `localhost:8000/api/`.
* An example `localhost:8000/api/texts/Berakhot.2a?commentary=1`
will get you the text and all the commentary of "Berakhot" book, page 2, sub-page "b".
* For more examples import `sefaria api.postman_collection.json` to Postman.

# Upload Images to AWS ECR
* Run:
```bash
./aws_push.sh
```

# Run Containers in AWS EC2
* Copy `docker-compose.cloud.yml` and `local_settings.py` to the EC2 machine.
* `local_settings.py` - allow access from any host.
* Run in EC2 machine:
```bash
docker.compose -f docker-compose.cloud.yml up -d
```

22 changes: 22 additions & 0 deletions docker-compose.cloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: '3'

services:
mongo:
restart: always
image: 058331968334.dkr.ecr.eu-central-1.amazonaws.com/shitufta-sefaria-db
ports:
- "27017:27017"
redis:
restart: always
image: redis
web:
restart: always
image: 058331968334.dkr.ecr.eu-central-1.amazonaws.com/shitufta-sefaria-api
command: bash -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
volumes:
- "$PWD/local_settings.py:/www/sefaria/local_settings.py" # allow access from any host
ports:
- "8000:8000"
depends_on:
- mongo
- redis
2 changes: 1 addition & 1 deletion local_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
relative_to_abs_path = lambda *x: os.path.join(os.path.dirname(
os.path.realpath(__file__)), *x)

ALLOWED_HOSTS = ["localhost", "127.0.0.1", "0.0.0.0"]
ALLOWED_HOSTS = ["localhost", "127.0.0.1", "0.0.0.0", "shitufta-ec2", "*"]
DEBUG = True
TEMPLATE_DEBUG = DEBUG
OFFLINE = False
Expand Down

0 comments on commit 3aa3016

Please sign in to comment.