Skip to content

Commit

Permalink
refactor: Restructure to use ENV to pull in ASSIGN (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
medwar99 authored Nov 14, 2024
1 parent 6f54974 commit fc22aef
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 41 deletions.
15 changes: 14 additions & 1 deletion containers/assign/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,20 @@ SHELL ["/bin/bash", "-c"]
# Get git.
RUN apt-get update && apt-get install -y git

ENV assign_url="https://github.com/endeavourhealth-discovery/ASSIGN.git"
ENV assign_dest="/data/ASSIGN"
ENV assign_sha=""
ENV abp_dir="/data/ABP"
ENV ydb_chset=M

# Create directory to hold ABP
RUN mkdir -p $abp_dir

# Add in startup script.
ADD startup_scripts/assign-startup.sh /assign-startup.sh
COPY startup_scripts/assign-startup.sh /assign-startup.sh
RUN chmod +x /assign-startup.sh

# Expose port for YottaDB GUI
EXPOSE 9080/tcp

ENTRYPOINT ["/assign-startup.sh"]
65 changes: 25 additions & 40 deletions startup_scripts/assign-startup.sh
Original file line number Diff line number Diff line change
@@ -1,52 +1,37 @@
#!/bin/bash
#################################################################
# #
# Copyright (c) 2024 YottaDB LLC and/or its subsidiaries. #
# All rights reserved. #
# #
# This source code contains the intellectual property #
# of its copyright holder(s), and is made available #
# under a license. If you do not know the terms of #
# the license, please stop and do not read further. #
# #
#################################################################

mkdir -p /data/logs

#set env vars
export ydb_chset=M
# Set env vars
. /opt/yottadb/current/ydb_env_set

#get ASSIGN
read -p "Enter ASSIGN git repo url (https://github.com/endeavourhealth-discovery/ASSIGN.git):" assign_url
assign_url=${assign_url:-"https://github.com/endeavourhealth-discovery/ASSIGN.git"}
read -p "Enter ASSIGN install path (./ASSIGN):" assign_dest
assign_dest=${assign_dest:-"./ASSIGN"}
read -p "Enter ASSIGN commit sha ( ):" sha
sha=${sha:-""}
assign_url="https://github.com/endeavourhealth-discovery/ASSIGN.git"
assign_dest="./ASSIGN"
sha=""
git clone $assign_url $assign_dest
git -C $assign_dest checkout $sha
cp $assign_dest/UPRN/yottadb/* $ydb_dir/$ydb_rel/r
mkdir ./ABP
cp $assign_dest/UPRN/codelists/* /data/ABP

#perform zlink of routines
$ydb_dist/ydb -run ^ZLINK

# extend database to hold ABP
# Get ASSIGN
if [ ! -d "$assign_dest" ]; then
echo "Obtaining ASSIGN routines."
# Clone the wanted sha from github
git clone $assign_url $assign_dest
git -C $assign_dest checkout $assign_sha

# Put the routines to the YottaDB routines directory
echo "Moving the routines."
cp $assign_dest/UPRN/yottadb/* $ydb_dir/$ydb_rel/r
cp $assign_dest/UPRN/codelists/* $abp_dir

# Perform zlink of routines
echo "Linking ASSIGN routines."
$ydb_dist/ydb -run ^ZLINK
else
echo "$assign_dest already exists. Not cloning down ASSIGN again."
fi

# Update YottaDB database settings
$ydb_dist/mupip set -NULL_SUBSCRIPTS=true -region DEFAULT && \
$ydb_dist/mupip set -journal=off -region DEFAULT && \
$ydb_dist/mupip set -extension_count=500000 -region DEFAULT && \
$ydb_dist/mupip set -access_method=mm -region DEFAULT
$ydb_dist/mupip extend DEFAULT -blocks=1700

#startup webgui
yottadb -run %ydbgui --readwrite --port 9080 >>/data/logs/%ydbgui.log &

#load in ABP straight away, we don't do this at the moment as it takes a long time and still has issues with encoding on codelist files.
#$ydb_dist/ydb -run %XCMD 'd IMPORT^UPRN1A("/data/ABP")'
# Startup webgui
yottadb -run %ydbgui --read --port 9080 >>/data/logs/%ydbgui.log &

#drop in to ydb
# Drop in to ydb
exec $ydb_dist/yottadb -direct

0 comments on commit fc22aef

Please sign in to comment.