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

Adjusted environments and scripts to clean up onboarding #148

Merged
merged 1 commit into from
Dec 29, 2019
Merged
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
41 changes: 19 additions & 22 deletions Orchestration/docker-compose-example.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
version: '3.1'

services:
# backend:
# build:
# context: ../python
# image: 311-data-back:0.0.1
# restart: always
# container_name: "311-backend"
# environment:
# SODAPY_APPTOKEN: <Your Token Here>
# ports:
# - 5000:5000
#
# frontend:
# build:
# context: ../javascript/react/311-data
# image: 311-data-front:0.0.1
# volumes:
# - '../javascript/react/311-data:/app'
# - '/app/node_modules'
# restart: always
# container_name: "311-frontend"
# ports:
# - 3000:3000
backend:
build:
context: ../server
image: 311-data-back:0.0.1
restart: always
container_name: "311-backend"
environment:
DB_CONNECTION_STRING: postgres://REDACTED:REDACTED@db:5432/postgres
ports:
- 5000:5000

frontend:
build:
context: ..
image: 311-data-front:0.0.1
restart: always
container_name: "311-frontend"
ports:
- 3000:3000

db:
image: postgres
Expand Down
4 changes: 2 additions & 2 deletions onboard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ if [ -f ./server/src/static/2018_mini.csv ]; then
else
echo "🕺 Downloading the first 10000 rows of the 2018 dataset for seeding"

curl 'https://data.lacity.org/resource/h65r-yf5i.csv?$select=*&$limit=10000' -o server/src/static/2018_mini.csv
curl 'https://data.lacity.org/resource/h65r-yf5i.csv?$select=SRNumber,CreatedDate,UpdatedDate,ActionTaken,Owner,RequestType,Status,RequestSource,MobileOS,Anonymous,AssignTo,ServiceDate,ClosedDate,AddressVerified,ApproximateAddress,Address,HouseNumber,Direction,StreetName,Suffix,ZipCode,Latitude,Longitude,Location,TBMPage,TBMColumn,TBMRow,APC,CD,CDMember,NC,NCName,PolicePrecinct&$limit=10000' -o server/src/static/2018_mini.csv

echo "Once the docker compose environment is setup you can send a POST request"
echo 'To /ingest with body argument of {"sets":["2018_MINI"]} to seed the db'
Expand All @@ -160,7 +160,7 @@ fi
while true; do
read -p "Do you wish to run the docker environment? (postgres, frontend, backend, adminer)?" yn
case $yn in
[Yy]* ) docker-compose -f ./Orchestration/docker-compose.yml up -d && exit;;
[Yy]* ) docker-compose -f ./Orchestration/docker-compose.yml up --build -d && exit;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
Expand Down
2 changes: 2 additions & 0 deletions server/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def configure_app():
settings_file = os.path.join(os.getcwd(),'settings.cfg')
config.read(settings_file)
app.config['Settings'] = config
if os.environ.get('DB_CONNECTION_STRING', None):
app.config['Settings']['Database']['DB_CONNECTION_STRING'] = os.environ.get('DB_CONNECTION_STRING')
app.config["STATIC_DIR"] = os.path.join(os.getcwd(), "static")
os.makedirs(os.path.join(app.config["STATIC_DIR"], "temp"), exist_ok=True)

Expand Down
2 changes: 1 addition & 1 deletion server/src/services/sqlIngest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def loadData(self, fileName="2018_mini"):
else:
dataFile = fileName + ".tsv"

self.filePath = os.path.join("../", self.config['Database']['DATA_DIRECTORY'], dataFile )
self.filePath = os.path.join(self.config['Database']['DATA_DIRECTORY'], dataFile )
print('Loading dataset %s' % self.filePath)
self.data = pd.read_table(self.filePath,
sep=self.separator,
Expand Down
2 changes: 1 addition & 1 deletion server/src/settings.example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PORT = 5000

[Database]
DB_CONNECTION_STRING = postgres://REDACTED:REDACTED@localhost:5432/postgres
DATA_DIRECTORY = .
DATA_DIRECTORY = static

[Api]
REDACTED = REDACTED
Expand Down
Loading