Skip to content

Commit

Permalink
Fix web build and env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaSBrown committed Feb 11, 2024
1 parent 6df9184 commit f494f54
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 51 deletions.
56 changes: 6 additions & 50 deletions scripts/install_ws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ SOURCE=$(dirname "$SCRIPT")
PROJECT_ROOT=$(realpath ${SOURCE}/..)
source ${PROJECT_ROOT}/config/datafed.sh
source ${SOURCE}/dependency_versions.sh
source ${SOURCE}/dependency_install_functions.sh

#NVM_DIR=/home/cades/.nvm
#[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
export NVM_DIR="/home/cades/.nvm"
source ${NVM_DIR}/nvm.sh
#export NVM_DIR="/home/cades/.nvm"
#source ${NVM_DIR}/nvm.sh
# Make sure paths exist
mkdir -p ${DATAFED_INSTALL_PATH}/web
mkdir -p ${DATAFED_INSTALL_PATH}/keys
Expand All @@ -20,54 +21,9 @@ mkdir -p ${DATAFED_DEFAULT_LOG_PATH}
# Install web node modules
cp "$PROJECT_ROOT/web/package.json" ${DATAFED_INSTALL_PATH}/web/

nvm use $DATAFED_NODE_VERSION
export npm_config_cache=${DATAFED_INSTALL_PATH}/web
# Check if npm exists
{
npm_path=$(which npm)
} || {
echo "npm_path not found."
}
if [ -z "$npm_path" ]
then

{
# Will return a result if nvm can be found and returns nothing otherwise
# which does not work with nvm
nvm_command_exists=$(command -v nvm)
} || {
echo "nvm_command_exists not found."
}

if [ -z "$nvm_path" ]
then
# Check for nvm in default location when installed with web dependencies
# script
if [ -d "$NVM_DIR" ]
then
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
elif [ -d "$HOME/.nvm" ]
then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
{
nvm_command_exists=$(command -v nvm)
} || {
echo "nvm_command_exists not found after sourcing."
}
if [ -z "$nvm_path" ]
then
echo "ERROR Unable to locate npm or nvm."
exit 1
fi
else
echo "ERROR Unable to locate npm or nvm."
exit 1
fi

fi
nvm use $DATAFED_NODE_VERSION
fi
install_nvm
install_node
install_foxx_cli
{
npm --allow-root --unsafe-perm --prefix ${DATAFED_INSTALL_PATH}/web install
} || {
Expand Down
2 changes: 2 additions & 0 deletions web/docker/Dockerfile.web-base.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ COPY ./scripts/dependency_install_functions.sh ${BUILD_DIR}/scripts/
COPY ./scripts/dependency_versions.sh ${BUILD_DIR}/scripts/
COPY ./scripts/install_ws_dependencies.sh ${BUILD_DIR}/scripts/

ENV DATAFED_DEPENDENCIES_INSTALL_PATH="${DATAFED_DIR}/dependenies"

# Docker dependency
RUN echo "#!/bin/bash\n\$@" > /usr/bin/sudo && chmod +x /usr/bin/sudo
RUN ${BUILD_DIR}/scripts/generate_datafed.sh
Expand Down
5 changes: 4 additions & 1 deletion web/docker/Dockerfile.web.ubuntu
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM camden.ornl.gov/datafed/ws-base:latest as build
ARG BASE_WEB_IMAGE="camden.ornl.gov/datafed/ws-base:latest"

FROM "$BASE_WEB_IMAGE" as build

ARG DATAFED_DIR="/datafed"
ARG BUILD_DIR="/datafed/source"
Expand All @@ -8,6 +10,7 @@ ARG DATAFED_INSTALL_PATH="/datafed/install"
ENV DATAFED_DIR="$DATAFED_DIR"
ENV BUILD_DIR="$BUILD_DIR"
ENV DATAFED_INSTALL_PATH="$DATAFED_INSTALL_PATH"
ENV DATAFED_DEPENDENCIES_INSTALL_PATH="${DATAFED_DIR}/dependenies"

RUN mkdir -p ${BUILD_DIR}/logs
RUN mkdir -p ${BUILD_DIR}/common/proto
Expand Down

0 comments on commit f494f54

Please sign in to comment.