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

entrypoint: support extensions #23

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 "$@"