forked from GeospatialResearch/Digital-Twins
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dynamic_building_outlines' into test_digitaltwin
- Loading branch information
Showing
151 changed files
with
26,035 additions
and
19,127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
visualisation | ||
tmp | ||
docs | ||
fredt.tar | ||
build_dep.tar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
# Ovverrides any values in .env that are being used for local development | ||
# Overrides any values in .env that are being used for local development | ||
# Values here are used inside the contianers using this file | ||
DATA_DIR=/stored_data | ||
DATA_DIR_SLR=/stored_data/slr_data | ||
DATA_DIR_REC=/stored_data/rec_data | ||
DATA_DIR_MODEL_OUTPUT=/stored_data/model_output | ||
DATA_DIR_GEOSERVER=/stored_data/geoserver | ||
FLOOD_MODEL_DIR=/bg_flood | ||
|
||
POSTGRES_PORT=5432 | ||
POSTGRES_HOST=db_postgres | ||
|
||
MESSAGE_BROKER_HOST=message_broker | ||
|
||
GEOSERVER_HOST=http://geoserver | ||
GEOSERVER_PORT=8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.sh text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,3 +128,4 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
/api_keys.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,99 @@ | ||
FROM continuumio/miniconda3 as base | ||
|
||
WORKDIR app/ | ||
FROM continuumio/miniconda3:23.10.0-1 AS build | ||
# Miniconda layer for building conda environment | ||
WORKDIR /app | ||
|
||
# Install mamba for faster conda solves | ||
RUN conda install -c conda-forge mamba | ||
|
||
# Create Conda environment | ||
COPY environment.yml . | ||
RUN conda env create -f environment.yml | ||
RUN mamba env create -f environment.yml | ||
|
||
# Make RUN commands use the new environment: | ||
SHELL ["conda", "run", "-n", "digitaltwin", "/bin/bash", "-c"] | ||
|
||
# Test that conda environment worked successfully | ||
RUN echo "Check GeoFabrics is installed to test environment" | ||
RUN python -c "import geofabrics" | ||
|
||
COPY selected_polygon.geojson . | ||
COPY src/ src/ | ||
# Pack conda environment to be shared to runtime image | ||
RUN conda-pack --ignore-missing-files -n digitaltwin -o /tmp/env.tar \ | ||
&& mkdir /venv \ | ||
&& cd /venv \ | ||
&& tar xf /tmp/env.tar \ | ||
&& rm /tmp/env.tar | ||
RUN /venv/bin/conda-unpack | ||
|
||
|
||
FROM lparkinson/bg_flood:v0.9 AS runtime-base | ||
# BG_Flood stage for running the digital twin. Reduces image size significantly if we use a multi-stage build | ||
WORKDIR /app | ||
|
||
USER root | ||
|
||
# Install dependencies | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends ca-certificates curl wget acl \ | ||
# Install firefox from mozilla .deb repository, not snap package as is default for ubuntu (snap does not work for docker) | ||
&& wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null \ | ||
&& echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | tee -a /etc/apt/sources.list.d/mozilla.list > /dev/null \ | ||
&& echo $' \n\ | ||
Package: * \n\ | ||
Pin: origin packages.mozilla.org \n\ | ||
Pin-Priority: 1000 \n\ | ||
' | tee /etc/apt/preferences.d/mozilla \ | ||
&& cat /etc/apt/preferences.d/mozilla \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends firefox \ | ||
# Install geckodriver, webdriver for firefox, needed for selenium | ||
&& curl --proto "=https" -L https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz | tar xz -C /usr/local/bin \ | ||
# Install health-checker tool that allows us to run commands when checking root endpoint to check if service is available | ||
&& wget -q https://github.com/gruntwork-io/health-checker/releases/download/v0.0.8/health-checker_linux_amd64 -O /usr/local/bin/health-checker \ | ||
&& chmod +x /usr/local/bin/health-checker \ | ||
# Cleanup image and remove junk | ||
&& rm -fr /var/lib/apt/lists/* \ | ||
# Remove unused packages. Keep curl for health checking in docker-compose | ||
&& apt-get purge -y ca-certificates wget | ||
|
||
# Create stored data dir inside image, in case it does not get mounted (such as when deploying on AWS) | ||
RUN mkdir /stored_data && setfacl -R -m u:nonroot:rwx /stored_data | ||
|
||
USER nonroot | ||
|
||
# Copy python virtual environment from build layer | ||
COPY --chown=nonroot:nonroot --chmod=544 --from=build /venv /venv | ||
|
||
# Using python virtual environment, preload selenium with firefox so that first runtime is faster. | ||
SHELL ["/bin/bash", "-c"] | ||
RUN source /venv/bin/activate && \ | ||
selenium-manager --browser firefox --debug | ||
|
||
# Copy source files and essential runtime files | ||
COPY --chown=nonroot:nonroot --chmod=444 selected_polygon.geojson . | ||
COPY --chown=nonroot:nonroot --chmod=644 instructions.json . | ||
COPY --chown=nonroot:nonroot --chmod=544 src/ src/ | ||
|
||
|
||
FROM runtime-base AS backend | ||
# Image build target for backend | ||
# Using separate build targets for each image because the Orbica platform does not allow for modifying entrypoints | ||
# and using multiple dockerfiles was creating increase complexity problems keeping things in sync | ||
EXPOSE 5000 | ||
ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "digitaltwin", "gunicorn", "--bind", "0.0.0.0:5000", "src.app:app"] | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
ENTRYPOINT source /venv/bin/activate && \ | ||
gunicorn --bind 0.0.0.0:5000 src.app:app | ||
|
||
|
||
FROM runtime-base AS celery_worker | ||
# Image build target for celery_worker | ||
|
||
EXPOSE 5001 | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
# Activate environment and run the health-checker in background and celery worker in foreground | ||
ENTRYPOINT source /venv/bin/activate && \ | ||
health-checker --listener 0.0.0.0:5001 --log-level error --script-timeout 10 \ | ||
--script "celery -A src.tasks inspect ping" & \ | ||
source /venv/bin/activate && \ | ||
celery -A src.tasks worker -P threads --loglevel=INFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
STATSNZ_API_KEY= | ||
LINZ_API_KEY= | ||
LRIS_API_KEY= | ||
MFE_API_KEY= | ||
NIWA_API_KEY= |
Oops, something went wrong.