Skip to content

Commit

Permalink
add_data: Download opendrr-boundaries.dump from S3
Browse files Browse the repository at this point in the history
- python/Dockerfile: Install zip and aws
- sample.env: Add AWS credentials [TODO]

Fixes #116
  • Loading branch information
anthonyfok committed Jun 17, 2021
1 parent 976ce6b commit 4252c0b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ COPY . .
#RUN chmod +x docker-entrypoint.sh && chmod +x add_data.sh
RUN chmod +x add_data.sh && \
apt-get update && \
apt-get install -y eatmydata git git-lfs jq time
apt-get install -y eatmydata git git-lfs jq time zip && \
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
./aws/install
#ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"]
CMD ./add_data.sh
3 changes: 2 additions & 1 deletion python/add_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ import_census_boundaries() {
LOG "## Importing Census Boundaries"

INFO "Trying to download pre-generated PostGIS database dump (for speed)..."
if RUN curl -O -v --retry 999 --retry-max-time 0 https://opendrr.eccp.ca/file/OpenDRR/opendrr-boundaries.dump || \
if RUN aws s3 sync s3://opendrr-api-prebuilt-cache-1/boundaries/ . --exclude "*" --include "opendrr-boundaries.dump" || \
RUN curl -O -v --retry 999 --retry-max-time 0 https://opendrr.eccp.ca/file/OpenDRR/opendrr-boundaries.dump || \
RUN curl -O -v --retry 999 --retry-max-time 0 https://f000.backblazeb2.com/file/OpenDRR/opendrr-boundaries.dump
then
RUN pg_restore -h "$POSTGRES_HOST" -U "$POSTGRES_USER" -d "$DB_NAME" \
Expand Down
5 changes: 5 additions & 0 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ loadPhysicalExposure=true
loadRiskDynamics=true
loadSocialFabric=true

# For downloading pre-built data, e.g. opendrr-boundaries.dump
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=ca-central-1

# For testing and debugging
#ADD_DATA_DRY_RUN=true
#ADD_DATA_DOWNLOAD_ONLY=true
Expand Down

0 comments on commit 4252c0b

Please sign in to comment.