Skip to content

Commit

Permalink
Working dev version of web server
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaSBrown committed Feb 16, 2024
1 parent 569cc50 commit edb3436
Show file tree
Hide file tree
Showing 27 changed files with 393 additions and 152 deletions.
6 changes: 6 additions & 0 deletions compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@

The files in this folder are incomplete but are the start for setting up a full
docker compose instance of datafed.

## Generate self signed web key

openssl genrsa -out cert.key 2048
openssl req -new -key cert.key -out cert.csr
openssl x509 -req -days 3650 -in cert.csr -signkey cert.key -out cert.crt
6 changes: 6 additions & 0 deletions compose/build_images_for_compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ docker build -f \
--build-arg RUNTIME="datafed-runtime" \
"${PROJECT_ROOT}" \
-t datafed-web:latest
docker build -f \
"${PROJECT_ROOT}/docker/Dockerfile.foxx" \
--build-arg DEPENDENCIES="datafed-dependencies" \
--build-arg RUNTIME="datafed-runtime" \
"${PROJECT_ROOT}" \
-t datafed-foxx:latest

43 changes: 36 additions & 7 deletions compose/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version: '3.9'

services:
datafed-web:
depends_on: ["datafed-core"]
environment:
DATAFED_GLOBUS_APP_SECRET: "${DATAFED_GLOBUS_APP_SECRET}"
DATAFED_GLOBUS_APP_ID: "${DATAFED_GLOBUS_APP_ID}"
Expand All @@ -12,14 +13,20 @@ services:
DATAFED_WEB_CERT_PATH: "${DATAFED_WEB_CERT_PATH}"
DATAFED_WEB_KEY_PATH: "${DATAFED_WEB_KEY_PATH}"
DATAFED_DEFAULT_LOG_PATH: "${DATAFED_CONTAINER_LOG_PATH}"
DATAFED_CORE_ADDRESS_PORT_INTERNAL: "datafed-core:7513"
UID: "${DATAFED_UID}"
image: datafed-web:latest
ports:
- 8080:443
volumes:
- keys:/opt/datafed/keys
- ./web_keys:/opt/datafed/web_keys

datafed-core:
image: datafed-core:latest
depends_on: ["arango"]
depends_on:
datafed-foxx:
condition: service_healthy
environment:
DATAFED_GLOBUS_APP_SECRET: "${DATAFED_GLOBUS_APP_SECRET}"
DATAFED_GLOBUS_APP_ID: "${DATAFED_GLOBUS_APP_ID}"
Expand All @@ -32,19 +39,41 @@ services:
UID: "${DATAFED_UID}"
DATAFED_DATABASE_PASSWORD: "${DATAFED_DATABASE_PASSWORD}"
DATAFED_DATABASE_IP_ADDRESS: "${DATAFED_DATABASE_IP_ADDRESS}"
DATAFED_DATABASE_IP_ADDRESS_PORT: "${DATAFED_DATABASE_IP_ADDRESS_PORT}"
ports:
- 7513 # Communication web server
- 7512 # Secure core server communication
volumes:
- keys:/opt/datafed/keys

datafed-foxx:
image: datafed-foxx:latest
depends_on: ["arango"]
environment:
DATAFED_ZEROMQ_SYSTEM_SECRET: "${DATAFED_ZEROMQ_SYSTEM_SECRET}"
DATAFED_DOMAIN: "${DATAFED_DOMAIN}"
DATAFED_DEFAULT_LOG_PATH: "${DATAFED_CONTAINER_LOG_PATH}"
UID: "${DATAFED_UID}"
DATAFED_DATABASE_PASSWORD: "${DATAFED_DATABASE_PASSWORD}"
DATAFED_DATABASE_IP_ADDRESS: "${DATAFED_DATABASE_IP_ADDRESS}"
DATAFED_DATABASE_HOST: "arango"
healthcheck:
test: ["CMD", "/bin/bash", "-c", "[ -f /tmp/.foxx_is_installed ]"]
interval: 10s
timeout: 5s
retries: 10

arango:
image: arangodb
environment:
ARANGO_ROOT_PASSWORD: "${ARANGO_ROOT_PASSWORD}"
ARANGO_ROOT_PASSWORD: "${DATAFED_DATABASE_PASSWORD}"
ports:
- 8529:8529 # Arangodb web UI
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8529/_admin/cluster/health"]
interval: 30s
timeout: 10s
retries: 5
# healthcheck:
# test: ["CMD", "curl", "-f", "http://localhost:8529/_admin/cluster/health"]
# interval: 30s
# timeout: 10s
# retries: 5

volumes:
keys:
22 changes: 17 additions & 5 deletions core/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ ARG DEPENDENCIES="dependencies"
ARG RUNTIME="runtime"
ARG DATAFED_DIR="/datafed"
ARG DATAFED_INSTALL_PATH="/opt/datafed"
ARG DATAFED_DEPENDENCIES_INSTALL_PATH="/opt/datafed/dependencies"
ARG GCS_IMAGE="code.ornl.gov:4567/dlsw/datafed/gcs-ubuntu-focal"
ARG BUILD_DIR="$DATAFED_DIR/source"
ARG NVM_DIR="$DATAFED_DIR/.nvm"
ARG NVM_INC="$DATAFED_DIR/.nvm/versions/node/v13.14.0/include/node"
ARG NVM_BIN="$DATAFED_DIR/.nvm/versions/node/v13.14.0/bin"
#ARG NVM_DIR="$DATAFED_DIR/.nvm"
#ARG NVM_INC="$DATAFED_DIR/.nvm/versions/node/v13.14.0/include/node"
#ARG NVM_BIN="$DATAFED_DIR/.nvm/versions/node/v13.14.0/bin"
ARG LIB_DIR="/usr/local/lib"

FROM ${DEPENDENCIES} AS core-build

SHELL ["/bin/bash", "-c"]

ARG DATAFED_DIR
ARG BUILD_DIR
ARG DATAFED_INSTALL_PATH
Expand Down Expand Up @@ -49,13 +52,16 @@ RUN cmake --build build --target install

FROM ${RUNTIME} AS core

SHELL ["/bin/bash", "-c"]

ARG DATAFED_DIR
ARG DATAFED_INSTALL_PATH
ARG BUILD_DIR
ARG LIB_DIR

# The above should also be available at runtime
ENV DATAFED_INSTALL_PATH="$DATAFED_INSTALL_PATH"
ENV DATAFED_DEPENDENCIES_INSTALL_PATH="${DATAFED_DEPENDENCIES_INSTALL_PATH}"
ENV DATAFED_DIR="$DATAFED_DIR"
ENV BUILD_DIR="$BUILD_DIR"
ENV LIB_DIR="$LIB_DIR"
Expand Down Expand Up @@ -83,5 +89,11 @@ COPY --from=core-build --chown=datafed:root ${DATAFED_INSTALL_PATH}/core/datafed

USER root

ENTRYPOINT ${BUILD_DIR}/core/entrypoint.sh
#CMD ["${DATAFED_INSTALL_PATH}/core/datafed-core","--cfg","${DATAFED_INSTALL_PATH}/core/datafed-core.cfg"]
RUN chown -R datafed:root /datafed
RUN chown -R datafed:root /opt

#SHELL ["/bin/bash"]
# NOTE docker does not recognize curly braces around variables in entrypoint
# and CMD
ENTRYPOINT [ "/datafed/source/core/entrypoint.sh", "/opt/datafed/core/datafed-core","--cfg", "/opt/datafed/core/datafed-core.cfg"]
#CMD ["$DATAFED_INSTALL_PATH/core/datafed-core","--cfg","$DATAFED_INSTALL_PATH/core/datafed-core.cfg"]
7 changes: 7 additions & 0 deletions core/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ SCRIPT=$(realpath "$0")
SOURCE=$(dirname "$SCRIPT")
PROJECT_ROOT=$(realpath ${SOURCE}/../..)

env
${PROJECT_ROOT}/scripts/generate_datafed.sh
${PROJECT_ROOT}/scripts/generate_core_config.sh
${PROJECT_ROOT}/scripts/install_core.sh
Expand All @@ -21,6 +22,9 @@ then
su -c "mkdir -p ${log_path}" datafed
fi

echo "Number of arguments is $#"
echo "arguments are $@"

if [ "$#" -eq 0 ]; then
echo "No arguments were passed, running bash"
exec "bash"
Expand All @@ -38,3 +42,6 @@ else
# If not do not by default send to log file
su datafed -c '"$@"' -- argv0 "$@"
fi

echo "Give a few minutes to debug the problem"
sleep 10000
12 changes: 8 additions & 4 deletions docker/Dockerfile.dependencies
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
ARG DATAFED_DIR="/datafed"
ARG DATAFED_INSTALL_PATH="/opt/datafed"
ARG DATAFED_DEPENDENCIES_INSTALL_PATH="/opt/datafed/dependencies"
ARG GCS_IMAGE="code.ornl.gov:4567/dlsw/datafed/gcs-ubuntu-focal"
ARG BUILD_DIR="$DATAFED_DIR/source"
ARG NVM_DIR="$DATAFED_DIR/.nvm"
ARG NVM_INC="$DATAFED_DIR/.nvm/versions/node/v13.14.0/include/node"
ARG NVM_BIN="$DATAFED_DIR/.nvm/versions/node/v13.14.0/bin"
#ARG NVM_DIR="$DATAFED_DEPENDENCIES_INSTALL_PATH/nvm"
ARG LIB_DIR="/usr/local/lib"

FROM ubuntu:focal

ARG NVM_DIR
SHELL ["/bin/bash", "-c"]
#ARG NVM_DIR
ARG DATAFED_DIR
ARG BUILD_DIR
ARG DATAFED_INSTALL_PATH
Expand All @@ -18,6 +18,7 @@ ARG LIB_DIR

ENV BUILD_DIR="${BUILD_DIR}"
ENV DATAFED_DIR="${DATAFED_DIR}"
ENV DATAFED_DEPENDENCIES_INSTALL_PATH="${DATAFED_DEPENDENCIES_INSTALL_PATH}"
ENV LIB_DIR="${LIB_DIR}"

RUN mkdir -p ${BUILD_DIR}
Expand All @@ -32,14 +33,17 @@ WORKDIR ${BUILD_DIR}
COPY ./scripts/dependency_install_functions.sh ${BUILD_DIR}/scripts/
COPY ./scripts/dependency_versions.sh ${BUILD_DIR}/scripts/
COPY ./scripts/install_dependencies.sh ${BUILD_DIR}/scripts/
COPY ./scripts/utils.sh ${BUILD_DIR}/scripts/utils.sh
COPY ./scripts/install_core_dependencies.sh ${BUILD_DIR}/scripts/
COPY ./scripts/install_repo_dependencies.sh ${BUILD_DIR}/scripts/
COPY ./scripts/install_ws_dependencies.sh ${BUILD_DIR}/scripts/
COPY ./scripts/install_authz_dependencies.sh ${BUILD_DIR}/scripts/
COPY ./scripts/generate_datafed.sh ${BUILD_DIR}/scripts/generate_datafed.sh

RUN echo "#!/bin/bash\n\$@" > /usr/bin/sudo && chmod +x /usr/bin/sudo

# run build scripts
RUN ${BUILD_DIR}/scripts/generate_datafed.sh
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC ${BUILD_DIR}/scripts/install_dependencies.sh

COPY ./scripts/copy_dependency.sh ${BUILD_DIR}/scripts/
Expand Down
19 changes: 15 additions & 4 deletions docker/Dockerfile.foxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ ARG DATAFED_DIR
ARG BUILD_DIR
ARG DATAFED_INSTALL_PATH

ENV BUILD_DIR="${BUILD_DIR}"
ENV DATAFED_DIR="${DATAFED_DIR}"

COPY ./core/CMakeLists.txt ${BUILD_DIR}/core/CMakeLists.txt
COPY ./CMakeLists.txt ${BUILD_DIR}
COPY ./scripts/dependency_versions.sh ${BUILD_DIR}/scripts/
COPY ./scripts/generate_datafed.sh ${BUILD_DIR}/scripts/
COPY ./cmake ${BUILD_DIR}/cmake
COPY ./docker/entrypoint_foxx.sh ${BUILD_DIR}/docker
COPY ./docker/entrypoint_foxx.sh ${BUILD_DIR}/docker/entrypoint_foxx.sh
COPY ./core/database ${BUILD_DIR}/core/database
COPY ./scripts/install_foxx.sh ${BUILD_DIR}/scripts/

ENV BUILD_DIR="${BUILD_DIR}"
ENV DATAFED_DIR="${DATAFED_DIR}"

# Create datafed user, prefer more secure login options than password
# Recommended to mount ssh public key on run
RUN adduser --disabled-password --gecos "" datafed
Expand All @@ -43,4 +43,15 @@ RUN chown -R datafed:root /opt/datafed
RUN chown -R datafed:root /var/log/datafed
RUN chown -R datafed:root ${DATAFED_DIR}

RUN curl -OL https://download.arangodb.com/arangodb38/DEBIAN/Release.key; apt-key add - < Release.key
#RUN wget -q https://www.arangodb.com/repositories/arangodb38/DEBIAN/Release.key -O- | apt-key add -
RUN echo 'deb https://download.arangodb.com/arangodb38/DEBIAN/ /' | tee /etc/apt/sources.list.d/arangodb.list
RUN apt update
RUN apt install arangodb3-client -y
RUN arangosh --version

USER root

WORKDIR ${DATAFED_DIR}

ENTRYPOINT ${BUILD_DIR}/docker/entrypoint_foxx.sh
8 changes: 5 additions & 3 deletions docker/Dockerfile.runtime
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ ARG DATAFED_DIR="/datafed"
ARG DATAFED_INSTALL_PATH="/opt/datafed"
ARG GCS_IMAGE="code.ornl.gov:4567/dlsw/datafed/gcs-ubuntu-focal"
ARG BUILD_DIR="$DATAFED_DIR/source"
ARG NVM_DIR="$DATAFED_DIR/.nvm"
ARG NVM_INC="$DATAFED_DIR/.nvm/versions/node/v13.14.0/include/node"
ARG NVM_BIN="$DATAFED_DIR/.nvm/versions/node/v13.14.0/bin"
#ARG NVM_DIR="$DATAFED_DIR/.nvm"
#ARG NVM_INC="$DATAFED_DIR/.nvm/versions/node/v13.14.0/include/node"
#ARG NVM_BIN="$DATAFED_DIR/.nvm/versions/node/v13.14.0/bin"
ARG LIB_DIR="/usr/local/lib"

FROM ubuntu:focal

SHELL ["/bin/bash", "-c"]
ARG DATAFED_DIR
ARG DATAFED_INSTALL_PATH
ARG DATAFED_DEPENDENCIES_INSTALL_PATH
ARG BUILD_DIR

ENV BUILD_DIR="${BUILD_DIR}"
Expand Down
76 changes: 45 additions & 31 deletions docker/entrypoint_foxx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,57 @@ fi

SCRIPT=$(realpath "$0")
SOURCE=$(dirname "$SCRIPT")
PROJECT_ROOT=$(realpath ${SOURCE}/../..)

${PROJECT_ROOT}/scripts/generate_datafed.sh


cmake -S. -B build \
-DBUILD_REPO_SERVER=False \
-DBUILD_AUTHZ=False \
-DBUILD_CORE_SERVER=False \
-DBUILD_WEB_SERVER=False \
-DBUILD_DOCS=False \
-DBUILD_PYTHON_CLIENT=False \
-DBUILD_FOXX=True \
-DINSTALL_FOXX=True

PROJECT_ROOT=$(realpath ${SOURCE}/../)

log_path="$DATAFED_DEFAULT_LOG_PATH"

if [ ! -d "${log_path}" ]
then
su -c "mkdir -p ${log_path}" datafed
fi

if [ "$#" -eq 0 ]; then
echo "No arguments were passed, running bash"
exec "bash"
exit 0
fi

datafed_core_exec=$(basename "$1")
if [ "${datafed_core_exec}" = "datafed-core" ]
cd "${PROJECT_ROOT}"
# Check to see if foxx has previously been installed
install_flag="/tmp/.foxx_is_installed"
if [ ! -f "$install_flag" ]
then
# Send output to log file
# For this to work all commands must be passed in as a single string
su datafed -c '"$@"' -- argv0 "$@" 2>&1 | tee "$log_path/datafed-core.log"
else
echo "Not sending output to datafed-core.log"
# If not do not by default send to log file
su datafed -c '"$@"' -- argv0 "$@"
su datafed -c "${PROJECT_ROOT}/scripts/generate_datafed.sh"

su datafed -c "cmake -S. -B build \
-DBUILD_REPO_SERVER=False \
-DBUILD_COMMON=False \
-DBUILD_AUTHZ=False \
-DBUILD_CORE_SERVER=False \
-DBUILD_WEB_SERVER=False \
-DBUILD_DOCS=False \
-DBUILD_PYTHON_CLIENT=False \
-DBUILD_FOXX=True \
-DINSTALL_FOXX=True"


su datafed -c "cmake --build build"

# Give arango container a minute to initialize
# should be replaced with health check at some point
sleep 10
su datafed -c "cmake --build build --target install"

#if [ "$#" -eq 0 ]; then
# echo "No arguments were passed, running bash"
# exec "bash"
# exit 0
#fi
touch "$install_flag"
fi

sleep 1000
#datafed_core_exec=$(basename "$1")
#if [ "${datafed_core_exec}" = "datafed-core" ]
#then
# # Send output to log file
# # For this to work all commands must be passed in as a single string
# su datafed -c '"$@"' -- argv0 "$@" 2>&1 | tee "$log_path/datafed-core.log"
#else
# echo "Not sending output to datafed-core.log"
# # If not do not by default send to log file
# su datafed -c '"$@"' -- argv0 "$@"
#fi
Loading

0 comments on commit edb3436

Please sign in to comment.