Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- 'master'
paths:
- 'modules/concH2oSoilSalinity_position_history_loader/**'
- 'modules/data_access/**'
- 'modules/common/**'
workflow_dispatch: {} # Allows trigger of workflow from web interface

env:
Expand Down
47 changes: 47 additions & 0 deletions modules/concH2oSoilSalinity_position_history_loader/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
####
#
# This dockerfile builds the concH2oSoilSalinity position-history loader.
# Must be built from the project root so common/ and data_access/ are in context:
# docker build --no-cache \
# -t concH2oSoilSalinity_position_history_loader:latest \
# -f modules/concH2oSoilSalinity_position_history_loader/Dockerfile .
#
###
FROM registry.access.redhat.com/ubi8/ubi-minimal

ARG MODULE_DIR="./modules"
ARG APP_DIR="concH2oSoilSalinity_position_history_loader"
ARG COMMON_DIR="common"
ARG DATA_ACCESS_DIR="data_access"
ARG CONTAINER_APP_DIR="/usr/src/app"
ENV PYTHONPATH="${PYTHONPATH}:${CONTAINER_APP_DIR}"

WORKDIR ${CONTAINER_APP_DIR}

COPY ${MODULE_DIR}/${APP_DIR}/requirements.txt ${CONTAINER_APP_DIR}/${APP_DIR}/app-requirements.txt
COPY ${MODULE_DIR}/${DATA_ACCESS_DIR}/requirements.txt ${CONTAINER_APP_DIR}/${APP_DIR}/data-access-requirements.txt

RUN update-ca-trust && \
microdnf update -y --disableplugin=subscription-manager && \
microdnf install -y --disableplugin=subscription-manager \
shadow-utils \
gcc \
libzstd \
python39 \
python39-pip \
python39-wheel \
python39-devel \
python39-setuptools && \
python3 -mpip install --no-cache-dir --upgrade pip setuptools wheel && \
python3 -mpip install --no-cache-dir -r ${CONTAINER_APP_DIR}/${APP_DIR}/app-requirements.txt && \
python3 -mpip install --no-cache-dir -r ${CONTAINER_APP_DIR}/${APP_DIR}/data-access-requirements.txt && \
microdnf remove -y --disableplugin=subscription-manager gcc cpp && \
microdnf clean all --disableplugin=subscription-manager && \
groupadd -g 9999 appuser && \
useradd -r -u 9999 -g appuser appuser

COPY ${MODULE_DIR}/${APP_DIR} ${CONTAINER_APP_DIR}/${APP_DIR}
COPY ${MODULE_DIR}/${COMMON_DIR} ${CONTAINER_APP_DIR}/${COMMON_DIR}
COPY ${MODULE_DIR}/${DATA_ACCESS_DIR} ${CONTAINER_APP_DIR}/${DATA_ACCESS_DIR}

USER appuser

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
from contextlib import closing
from functools import partial
from pathlib import Path

import environs
import structlog

import common.log_config as log_config
from data_access.db_config_reader import read_from_mount
from data_access.db_connector import DbConnector
from data_access.get_enviroscan_asset_installs import get_enviroscan_asset_installs
from data_access.get_enviroscan_cvald1_calibrations import get_enviroscan_cvald1_calibrations
from data_access.get_enviroscan_cfgloc_vers import get_enviroscan_cfgloc_vers
from data_access.get_named_location_geolocations import get_named_location_geolocations
from data_access.get_named_location_parents import get_named_location_parents

import concH2oSoilSalinity_position_history_loader.concH2oSoilSalinity_position_history_loader as loader

log = structlog.get_logger()


def main() -> None:
env = environs.Env()
out_path: Path = env.path('OUT_PATH')
err_path: Path = env.path('ERR_PATH')
log_level: str = env.log_level('LOG_LEVEL', 'INFO')
log_config.configure(log_level)
log.debug(f'out_path: {out_path}')

db_config = read_from_mount(Path('/var/db_secret'))
with closing(DbConnector(db_config)) as connector:
loader.write_files(
get_asset_installs=partial(get_enviroscan_asset_installs, connector),
get_calibrations=partial(get_enviroscan_cvald1_calibrations, connector),
get_cfgloc_vers=partial(get_enviroscan_cfgloc_vers, connector),
get_geolocations=partial(get_named_location_geolocations, connector),
get_parents=partial(get_named_location_parents, connector),
out_path=out_path,
err_path=err_path,
)


if __name__ == '__main__':
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
structlog==21.5.0
environs==11.0.0
marshmallow==3.21.3
geojson==2.4.1
Loading