Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add full local setup with docker #265

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.7

RUN apt-get update && apt-get install -y postgresql libpq-dev && \
pip install --upgrade pip setuptools wheel

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /code

COPY . requirements.txt app.py manage.py wsgi.py /code/

RUN pip install -r requirements.txt

CMD python manage.py migrate && python app.py
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ While it is possible to run your development environment inside of the system Py
```
I usually store it at `private/environment.sh`. Load up these environment variables by running `source private/environment.sh` at the Bash prompt.

#### MacOS Install

1. `brew update; brew install postgresql`
2. `pip install --upgrade pip setuptools wheel`
3. `pip install -r requirements.txt`
4. Create a file for your environment variables that contains at least these:
```
export DOMAIN_NAME="localhost://8080"
export FLASK_SECRET_KEY="asdf"
export S3_BUCKET="a"
export SYSADMIN_EMAILS="sysadmin@localhost"
```
I usually store it at `private/environment.sh`. Load up these environment variables by running `source private/environment.sh` at the Bash prompt.

For additional tips on running a local development enironment please see [this wiki page](https://github.com/onnela-lab/beiwe-backend/wiki/Tips-For-Local-Beiwe-Development). If you are having difficulty getting started, or believe you could assist with any issues of documentation, please [post an issue with a documentation tag](https://github.com/onnela-lab/beiwe-backend/labels/documentation).

### Local Celery setup
Expand All @@ -93,7 +107,7 @@ For those souls brave enough to run the entire broker queue and Celery task disp
2. `pip install -r requirements_data_processing.txt` (this will install Celery using pip)
3. Create a file called `manager_ip` in the top level of your `beiwe-backend` repo, and enter these two lines in it. Do not provide a trailing new-line character.
```
127.0.0.1:50000
mq:50000
[YOUR DESIRED PASSWORD]
```
Where the password is the one you set when setting up RabbitMQ
Expand Down
1 change: 1 addition & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

# The name of the S3 bucket that will be used to store user generated data.
S3_BUCKET = getenv("S3_BUCKET")
S3_ENDPOINT = getenv("S3_ENDPOINT", None)

# Domain name for the server, this is used for various details, and should be match the address of
# the frontend server.
Expand Down
30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: "3.8"
services:
# db:
# image: "postgresql:14"
mq:
image: "rabbitmq:latest"
environment:
- RABBITMQ_DEFAULT_USER=beiwe
- RABBITMQ_DEFAULT_PASS=beiwe
- RABBITMQ_ERLANG_COOKIE='takeMyCookies'
storage:
image: minio/minio
environment:
- MINIO_ACCESS_KEY=minioadmin
- MINIO_SECRET_KEY=minioadmin
ports:
- "9000:9000"
command: server /data
backend:
build: .
environment:
- DOMAIN_NAME=localhost://8080
- FLASK_SECRET_KEY=asdf
- S3_BUCKET=beiwe
- S3_ENDPOINT=http://storage:9000
- SYSADMIN_EMAILS=sysadmin@localhost
- BEIWE_SERVER_AWS_ACCESS_KEY_ID=minioadmin
- BEIWE_SERVER_AWS_SECRET_ACCESS_KEY=minioadmin
ports:
- "8080:8080"
5 changes: 3 additions & 2 deletions libs/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Crypto

from config.settings import (BEIWE_SERVER_AWS_ACCESS_KEY_ID, BEIWE_SERVER_AWS_SECRET_ACCESS_KEY,
S3_BUCKET, S3_REGION_NAME)
S3_BUCKET, S3_REGION_NAME, S3_ENDPOINT)
from libs.encryption import (decrypt_server, encrypt_for_server, generate_key_pairing,
get_RSA_cipher, prepare_X509_key_for_java)

Expand Down Expand Up @@ -31,7 +31,8 @@ class NoSuchKeyException(Exception): pass
's3',
aws_access_key_id=BEIWE_SERVER_AWS_ACCESS_KEY_ID,
aws_secret_access_key=BEIWE_SERVER_AWS_SECRET_ACCESS_KEY,
region_name=S3_REGION_NAME
region_name=S3_REGION_NAME,
endpoint_url=S3_ENDPOINT
)


Expand Down