Skip to content

Commit

Permalink
Merge pull request #23 from chaen/extensions
Browse files Browse the repository at this point in the history
entrypoint: support extensions
  • Loading branch information
chrisburr authored Oct 1, 2024
2 parents d736d73 + ffb6d99 commit c7be768
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This repository contains the recipes and CI for building the base images used by DiracX.

See [documentation](https://github.com/DIRACGrid/diracx/blob/main/docs/VERSIONING.md#container-images)

## Available images

### secret-generation
Expand All @@ -11,3 +13,14 @@ This image is used by the [helm chart](https://github.com/DIRACGrid/diracx-chart
### server-base

This image is used as the base of the diracx service image.


## How to build

The most up to date documentation on how to build is the [CI job](.github/workflows/main.yml)

```bash

docker build -t ghcr.io/diracgrid/diracx/base:latest base
docker build -t ghcr.io/diracgrid/diracx/servces-base:latest services-base/
```
37 changes: 28 additions & 9 deletions base/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ eval "$(micromamba shell hook --shell=posix)"
micromamba activate base

function install_sources() {
extension_name=$1
source_prefix=$2
image_packages=$3

IFS=','
to_install=()
for dir in ${DIRACX_CUSTOM_SOURCE_PREFIXES}; do
for package_name in ${DIRACX_IMAGE_PACKAGES}; do
for dir in ${!source_prefix}; do
for package_name in ${!image_packages}; do
if [[ "${package_name}" == "." ]]; then
wheel_name="diracx"
wheel_name="${extension_name}"
else
wheel_name="diracx_${package_name}"
wheel_name="${extension_name}_${package_name}"
fi
wheels=( $(find "${dir}" -name "${wheel_name}-*.whl") )
if [[ ${#wheels[@]} -gt 1 ]]; then
Expand All @@ -26,9 +30,6 @@ function install_sources() {
else
src_dir=("${dir}-${package_name}")
fi
if [[ -n "${DIRACX_CUSTOM_SOURCE_EDITABLE:-}" ]]; then
to_install+=("-e")
fi
if [[ -f "${src_dir}/pyproject.toml" ]]; then
to_install+=("${src_dir}")
fi
Expand All @@ -40,8 +41,26 @@ function install_sources() {
fi
}

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

# If we have extensions, we install them all the same way
if [[ -n "${DIRACX_EXTENSIONS:-}" ]]; then

# Loop over the extension in reverse order
IFS=', ' read -r -a extension_array <<< "$DIRACX_EXTENSIONS"
for (( idx=${#extension_array[@]}-1 ; idx>=0 ; idx-- )) ; do

extension_name="${extension_array[idx]}"
source_prefix="${extension_name^^}_CUSTOM_SOURCE_PREFIXES"
image_packages="${extension_name^^}_IMAGE_PACKAGES"

if [[ -n "${!source_prefix:-}" ]]; then
install_sources "${extension_name}" "${source_prefix}" "${image_packages}"
fi
done
# No extensions, just diracx
elif [[ -n "${DIRACX_CUSTOM_SOURCE_PREFIXES:-}" ]]; then
install_sources "diracx" "DIRACX_CUSTOM_SOURCE_PREFIXES" "DIRACX_IMAGE_PACKAGES"
fi


exec "$@"

0 comments on commit c7be768

Please sign in to comment.