Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blake nedved rework docker building #916

Merged
merged 28 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
694e538
added new dockerfile with support for core and repo server
nedvedba Oct 24, 2023
71aea99
optimized web server build steps
nedvedba Oct 25, 2023
7ac9037
added gcs-authz container build
nedvedba Oct 26, 2023
c0973aa
started using unified dep install script
nedvedba Nov 1, 2023
425583c
optmized positioning of apt installs
nedvedba Nov 2, 2023
bd860cb
Changed ci config to new build system
nedvedba Nov 6, 2023
3e8546b
added script to copy dependencies with dynamic versions
nedvedba Nov 8, 2023
9eee328
split up Dockerfile into multiple files
nedvedba Nov 29, 2023
6cb2c3a
finished splitting dockerfiles and updating CI
nedvedba Dec 13, 2023
0dfaf5e
changed files to be owned by the root group for openshift
nedvedba Dec 13, 2023
79360fa
updated gitlab ci config
nedvedba Dec 19, 2023
b85cce6
added unified install scripts
nedvedba Dec 20, 2023
85a576a
applied suggested changes from PR
nedvedba Dec 20, 2023
b3b3ef8
removed script
nedvedba Dec 20, 2023
14f84f8
fixed incorrect flag
nedvedba Dec 20, 2023
8b7c30a
applied suggested changes from #916
nedvedba Dec 21, 2023
4953f01
moved dockerfiles to relevant directories
nedvedba Dec 21, 2023
8a3f886
applied more suggested changes from #916
nedvedba Dec 23, 2023
d678e9a
added comment to all install scripts
nedvedba Jan 2, 2024
308f440
fixed merged conflicts
nedvedba Jan 2, 2024
65fc6c1
fixed building issues
nedvedba Jan 2, 2024
ffe0a94
updated changelog
nedvedba Jan 2, 2024
72b3997
fixed codacity warning
nedvedba Jan 2, 2024
cfc75b4
swapped to using pre built dependencies for the gcs image
nedvedba Jan 2, 2024
65007ed
copied headers to build executable
nedvedba Jan 2, 2024
2dbc3cc
removed old version of zmq
nedvedba Jan 2, 2024
5d9480b
added missing library directory env
nedvedba Jan 3, 2024
ab4e9bc
fixed gcs build by adding missing dependencies
nedvedba Jan 3, 2024
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
223 changes: 156 additions & 67 deletions .gitlab-ci.yml

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions dockerfiles/core.Dockerfile
nedvedba marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
ARG BUILD_BASE="ubuntu:focal"
ARG DEPENDENCIES="dependencies"
ARG RUNTIME="runtime"
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 LIB_DIR="/usr/local/lib"

FROM ${DEPENDENCIES} AS core-build

ARG DATAFED_DIR
ARG BUILD_DIR
ARG DATAFED_INSTALL_PATH

# For communicating with repo server
EXPOSE 7512
# For listening to web server
EXPOSE 7513

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 ./scripts/generate_core_config.sh ${BUILD_DIR}/scripts/
COPY ./scripts/install_core.sh ${BUILD_DIR}/scripts/
COPY ./cmake ${BUILD_DIR}/cmake
COPY ./core/docker/entrypoint.sh ${BUILD_DIR}/core/docker/
COPY ./core/server ${BUILD_DIR}/core/server

# All files should be owned by the datafed user
# RUN chown -R datafed:datafed ${DATAFED_DIR}
#
# USER datafed
nedvedba marked this conversation as resolved.
Show resolved Hide resolved

RUN ${BUILD_DIR}/scripts/generate_datafed.sh && \
cmake -S. -B build \
-DBUILD_REPO_SERVER=False \
-DBUILD_AUTHZ=False \
-DBUILD_CORE_SERVER=True \
-DBUILD_WEB_SERVER=False \
-DBUILD_DOCS=False \
-DBUILD_PYTHON_CLIENT=False \
-DBUILD_FOXX=False
RUN cmake --build build -j 8
RUN cmake --build build --target install

FROM ${RUNTIME} AS core

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_DIR="$DATAFED_DIR"
ENV BUILD_DIR="$BUILD_DIR"
ENV LIB_DIR="$LIB_DIR"

# copy necessary shared libraries
COPY --from=core-build /libraries/libprotobuf.so /libraries/libprotobuf.so
COPY --from=core-build /libraries/libzmq.so /libraries/libzmq.so
COPY --from=core-build /libraries/libsodium.so /libraries/libsodium.so
COPY --from=core-build /libraries/libboost_program_options.so /libraries/libboost_program_options.so
RUN ${BUILD_DIR}/scripts/copy_dependency.sh protobuf to
RUN ${BUILD_DIR}/scripts/copy_dependency.sh libzmq to
RUN ${BUILD_DIR}/scripts/copy_dependency.sh libsodium to
RUN ${BUILD_DIR}/scripts/copy_dependency.sh boost_program_options to

RUN ldconfig

USER datafed

COPY --chown=datafed:root ./scripts/generate_datafed.sh ${DATAFED_DIR}/scripts/generate_datafed.sh
COPY --chown=datafed:root ./scripts/generate_core_config.sh ${DATAFED_DIR}/scripts/generate_core_config.sh
COPY --chown=datafed:root ./scripts/install_core.sh ${DATAFED_DIR}/scripts/install_core.sh
COPY --chown=datafed:root ./cmake/Version.cmake ${DATAFED_DIR}/cmake/Version.cmake
COPY --from=core-build --chown=datafed:root ${BUILD_DIR}/core/docker/entrypoint.sh ${BUILD_DIR}/core/entrypoint.sh
COPY --from=core-build --chown=datafed:root ${DATAFED_INSTALL_PATH}/core/datafed-core ${DATAFED_INSTALL_PATH}/core/datafed-core

ENTRYPOINT ["${BUILD_DIR}/core/entrypoint.sh"]
CMD ["${DATAFED_INSTALL_PATH}/core/datafed-core","--cfg","${DATAFED_INSTALL_PATH}/core/datafed-core.cfg"]
60 changes: 60 additions & 0 deletions dockerfiles/dependencies.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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 LIB_DIR="/usr/local/lib"

FROM ubuntu:focal

ARG NVM_DIR
ARG DATAFED_DIR
ARG BUILD_DIR
ARG DATAFED_INSTALL_PATH
ARG DEBIAN_FRONTEND=noninteractive
ARG LIB_DIR

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

RUN mkdir -p ${BUILD_DIR}
RUN mkdir -p ${BUILD_DIR}/logs
RUN mkdir -p ${BUILD_DIR}/repository/server
RUN mkdir -p ${BUILD_DIR}/common/proto
RUN mkdir -p /libraries
RUN mkdir -p ${NVM_DIR}

WORKDIR ${BUILD_DIR}

# Copy install scripts
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/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/

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

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

nedvedba marked this conversation as resolved.
Show resolved Hide resolved
COPY ./scripts/copy_dependency.sh ${BUILD_DIR}/scripts/
RUN ${BUILD_DIR}/scripts/copy_dependency.sh protobuf from
RUN ${BUILD_DIR}/scripts/copy_dependency.sh libzmq from
RUN ${BUILD_DIR}/scripts/copy_dependency.sh libsodium from
RUN ${BUILD_DIR}/scripts/copy_dependency.sh boost_program_options from
RUN ${BUILD_DIR}/scripts/copy_dependency.sh boost_filesystem from

RUN mkdir -p ${DATAFED_INSTALL_PATH}
RUN mkdir -p ${DATAFED_INSTALL_PATH}/keys

WORKDIR ${BUILD_DIR}

COPY ./common ${BUILD_DIR}/common

# RUN cp -R $HOME/.nvm ${NVM_DIR}
96 changes: 96 additions & 0 deletions dockerfiles/gcs.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
ARG BUILD_BASE="ubuntu:focal"
ARG DEPENDENCIES="dependencies"
ARG RUNTIME="runtime"
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 LIB_DIR="/usr/local/lib"

FROM ${GCS_IMAGE}

ARG DATAFED_DIR
ARG BUILD_DIR
ARG DATAFED_INSTALL_PATH

RUN mkdir -p ${BUILD_DIR}
RUN mkdir -p ${BUILD_DIR}/logs
RUN mkdir -p ${BUILD_DIR}/common/proto
RUN mkdir -p ${DATAFED_INSTALL_PATH}/authz
RUN mkdir -p ${DATAFED_DIR}/collections/mapped

RUN apt update
RUN apt install -y vim netcat

# For communicating with public
EXPOSE 443

# Needed for Globus GridFTP communication
EXPOSE 50000-51000

WORKDIR ${BUILD_DIR}

RUN adduser --disabled-password --gecos "" datafed

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

COPY ./scripts/dependency_versions.sh ${BUILD_DIR}/scripts/
COPY ./scripts/dependency_install_functions.sh ${BUILD_DIR}/scripts/
COPY ./scripts/install_authz_dependencies.sh ${BUILD_DIR}/scripts/

RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC ${BUILD_DIR}/scripts/install_authz_dependencies.sh

ARG rebuild=true
ARG DATAFED_DIR
ARG BUILD_DIR
ARG DATAFED_INSTALL_PATH

ENV GCS_COLLECTION_ROOT_PATH="$DATAFED_DIR/collections/mapped"
ENV DATAFED_INSTALL_PATH="$DATAFED_INSTALL_PATH"
ENV DATAFED_DIR="$DATAFED_DIR"
ENV BUILD_DIR="$BUILD_DIR"


# All files should be owned by the datafed user
RUN chown -R datafed:datafed ${DATAFED_DIR}
nedvedba marked this conversation as resolved.
Show resolved Hide resolved

COPY --chown=datafed:root ./scripts/dependency_versions.sh ${BUILD_DIR}/scripts/
COPY --chown=datafed:root ./scripts/generate_authz_config.sh ${BUILD_DIR}/scripts/generate_authz_config.sh
COPY --chown=datafed:root ./scripts/generate_datafed.sh ${BUILD_DIR}/scripts/generate_datafed.sh
COPY --chown=datafed:root ./CMakeLists.txt ${BUILD_DIR}
COPY --chown=datafed:root ./cmake ${BUILD_DIR}/cmake
COPY --chown=datafed:root ./repository/CMakeLists.txt ${BUILD_DIR}/repository/CMakeLists.txt
COPY --chown=datafed:root ./repository/gridftp/CMakeLists.txt ${BUILD_DIR}/repository/gridftp/CMakeLists.txt
COPY --chown=datafed:root ./scripts/globus/setup_globus.sh ${BUILD_DIR}/scripts/globus/setup_globus.sh
COPY --chown=datafed:root ./scripts/globus/generate_repo_form.sh ${BUILD_DIR}/scripts/globus/generate_repo_form.sh
COPY --chown=datafed:root ./repository/docker/entrypoint_authz.sh ${BUILD_DIR}/repository/docker/entrypoint_authz.sh
COPY --chown=datafed:root ./common ${BUILD_DIR}/common
COPY --chown=datafed:root ./repository/gridftp/globus5 ${BUILD_DIR}/repository/gridftp/globus5

# Build as if a non root user
USER datafed

RUN ${BUILD_DIR}/scripts/generate_datafed.sh

RUN ${BUILD_DIR}/scripts/generate_authz_config.sh && \
cmake -S. -B build \
-DBUILD_REPO_SERVER=False \
-DBUILD_AUTHZ=True \
-DBUILD_CORE_SERVER=False \
-DBUILD_WEB_SERVER=False \
-DBUILD_DOCS=False \
-DBUILD_PYTHON_CLIENT=False \
-DBUILD_FOXX=False
RUN cmake --build build
RUN cmake --build build --target install

COPY ./scripts/globus/setup_globus.sh ${BUILD_DIR}/scripts/globus/setup_globus.sh
COPY ./scripts/globus/generate_repo_form.sh ${BUILD_DIR}/scripts/globus/generate_repo_form.sh
COPY ./repository/docker/entrypoint_authz.sh ${BUILD_DIR}/repository/docker/entrypoint_authz.sh
nedvedba marked this conversation as resolved.
Show resolved Hide resolved

USER root

WORKDIR ${DATAFED_INSTALL_PATH}/authz
86 changes: 86 additions & 0 deletions dockerfiles/repo.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
ARG BUILD_BASE="ubuntu:focal"
ARG DEPENDENCIES="dependencies"
ARG RUNTIME="runtime"
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 LIB_DIR="/usr/local/lib"

FROM ${DEPENDENCIES} AS repo-build

ARG DATAFED_DIR
ARG BUILD_DIR
ARG DATAFED_INSTALL_PATH

# This port is needed to communicate with the DataFed core server
EXPOSE 7512
# Not quite sure what 9000 is doing that 7512 isn't, difference between egress
# and ingress?
EXPOSE 9000

COPY ./repository/CMakeLists.txt ${BUILD_DIR}/repository/CMakeLists.txt
COPY ./CMakeLists.txt ${BUILD_DIR}
COPY ./scripts/dependency_versions.sh ${BUILD_DIR}/scripts/
COPY ./scripts/dependency_install_functions.sh ${BUILD_DIR}/scripts/
COPY ./scripts/generate_datafed.sh ${BUILD_DIR}/scripts/
COPY ./scripts/generate_repo_config.sh ${BUILD_DIR}/scripts/
COPY ./scripts/install_repo.sh ${BUILD_DIR}/scripts/
COPY ./cmake ${BUILD_DIR}/cmake
COPY ./repository/server ${BUILD_DIR}/repository/server

RUN ${BUILD_DIR}/scripts/generate_datafed.sh && \
cmake -S. -B build \
-DBUILD_REPO_SERVER=True \
-DBUILD_AUTHZ=False \
-DBUILD_CORE_SERVER=False \
-DBUILD_WEB_SERVER=False \
-DBUILD_DOCS=False \
-DBUILD_PYTHON_CLIENT=False \
-DBUILD_FOXX=False
RUN cmake --build build
RUN cmake --build build --target install

FROM ${RUNTIME} AS repo

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_DIR="$DATAFED_DIR"
ENV BUILD_DIR="$BUILD_DIR"
ENV LIB_DIR="$LIB_DIR"

WORKDIR /datafed

# copy necessary shared libraries
COPY --from=repo-build /libraries/libprotobuf.so /libraries/libprotobuf.so
COPY --from=repo-build /libraries/libzmq.so /libraries/libzmq.so
COPY --from=repo-build /libraries/libsodium.so /libraries/libsodium.so
COPY --from=repo-build /libraries/libboost_program_options.so /libraries/libboost_program_options.so
COPY --from=repo-build /libraries/libboost_filesystem.so /libraries/libboost_filesystem.so
RUN ${BUILD_DIR}/scripts/copy_dependency.sh protobuf to
RUN ${BUILD_DIR}/scripts/copy_dependency.sh libzmq to
RUN ${BUILD_DIR}/scripts/copy_dependency.sh libsodium to
RUN ${BUILD_DIR}/scripts/copy_dependency.sh boost_program_options to
RUN ${BUILD_DIR}/scripts/copy_dependency.sh boost_filesystem to

RUN ldconfig

USER datafed

COPY --chown=datafed:root ./repository/docker/entrypoint_repo.sh ${BUILD_DIR}/repository/entrypoint.sh
COPY --chown=datafed:root ./scripts/generate_datafed.sh ${DATAFED_DIR}/scripts/generate_datafed.sh
COPY --chown=datafed:root ./scripts/generate_repo_config.sh ${DATAFED_DIR}/scripts/generate_repo_config.sh
COPY --chown=datafed:root ./scripts/install_repo.sh ${DATAFED_DIR}/scripts/install_repo.sh
COPY --chown=datafed:root ./cmake/Version.cmake ${DATAFED_DIR}/cmake/Version.cmake
COPY --from=repo-build --chown=datafed:root ${DATAFED_INSTALL_PATH}/repo/datafed-repo ${DATAFED_INSTALL_PATH}/repo/datafed-repo

ENTRYPOINT ["${BUILD_DIR}/repository/entrypoint.sh"]
CMD ["${DATAFED_INSTALL_PATH}/repo/datafed-repo","--cfg","${DATAFED_INSTALL_PATH}/repo/datafed-repo.cfg"]
37 changes: 37 additions & 0 deletions dockerfiles/runtime.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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 LIB_DIR="/usr/local/lib"

FROM ubuntu:focal

ARG DATAFED_DIR
ARG DATAFED_INSTALL_PATH
ARG BUILD_DIR

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

RUN echo $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

COPY ./scripts/dependency_versions.sh ${BUILD_DIR}/scripts/
COPY ./scripts/copy_dependency.sh ${BUILD_DIR}/scripts/
RUN mkdir -p ${DATAFED_DIR}
RUN mkdir -p /opt/datafed
RUN mkdir -p /var/log/datafed
RUN chown -R datafed:root /opt/datafed
RUN chown -R datafed:root /var/log/datafed
RUN chown -R datafed:root ${DATAFED_DIR}
WORKDIR ${DATAFED_DIR}

RUN apt update
RUN apt install -y grep libcurl4
# ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib:/usr/local/lib"
Loading
Loading