Skip to content

Commit

Permalink
Make entrypoint support installing unreleased versions
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisburr committed Nov 27, 2023
1 parent 5ee6636 commit 01b311c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
31 changes: 31 additions & 0 deletions base/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,35 @@ set -e

eval "$(micromamba shell hook --shell=posix)"
micromamba activate base

function install_sources() {
IFS=','
for dir in ${DIRACX_CUSTOM_SOURCE_PREFIXES}; do
for package_name in ${DIRACX_IMAGE_PACKAGES}; do
if [[ "${package_name}" == "." ]]; then
wheel_name="diracx"
else
wheel_name="diracx_${package_name}"
fi
wheels=("${dir}/${wheel_name}"-*.whl)
if [[ ${wheels[#]} -gt 1 ]]; then
echo "ERROR: Multiple wheels found for ${package_name} in ${dir}"
exit 1
elif [[ ${wheels[#]} -eq 1 ]]; then
pip install "${wheels[0]}"
elif [[ -d "${dir}-${package_name}" ]] || [[ "${package_name}" == "." ]]; then
if [[ -n "${DIRACX_CUSTOM_SOURCE_EDITABLE:-}" ]]; then
pip install -e "${dir}-${package_name}"
else
pip install "${dir}-${package_name}"
fi
fi
done
done
}

if [[ -n "${DIRACX_CUSTOM_SOURCE_PREFIXES:-}" ]]; then
install_sources
fi

exec "$@"
5 changes: 2 additions & 3 deletions client-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
FROM ghcr.io/diracgrid/diracx/base


# Copying in ENTRYPOINT script and environment specification
COPY --chown=$MAMBA_USER:$MAMBA_USER environment.yml /tmp/

ENV DIRACX_IMAGE_PACKAGES=core,client,api,cli,.

RUN micromamba install --freeze-installed --yes --file /tmp/environment.yml --name=base && \
micromamba clean --all --yes --force-pkgs-dirs && \
rm -rf /tmp/environment.yml


# In many clusters the container is ran as a random uid for security reasons.
# If we mark the conda directory as group 0 and give it group write permissions
# then we're still able to manage the environment from inside the container.
USER 0
RUN chown -R $MAMBA_USER:0 /opt/conda && chmod -R g=u /opt/conda
USER $MAMBA_USER

2 changes: 2 additions & 0 deletions services-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ EXPOSE 8000
# Copying in ENTRYPOINT script and environment specification
COPY --chown=$MAMBA_USER:$MAMBA_USER environment.yml /tmp/

ENV DIRACX_IMAGE_PACKAGES=core,db,routers

RUN micromamba install --freeze-installed --yes --file /tmp/environment.yml --name=base && \
micromamba clean --all --yes --force-pkgs-dirs && \
rm -rf /tmp/environment.yml
Expand Down

0 comments on commit 01b311c

Please sign in to comment.