Skip to content

Commit 07ca706

Browse files
committed
Move MARKETPLACE_DIR into Dockerfile so 10.x is supported
1 parent 3a87108 commit 07ca706

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

.github/workflows/glpi.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ jobs:
9797
name: "Prepare"
9898
runs-on: "ubuntu-latest"
9999
outputs:
100-
marketplace-dir: ${{ steps.set-vars.outputs.marketplace_dir }}
101100
artifact-prefix: ${{ steps.set-vars.outputs.artifact_prefix }}
102101
is-latest: ${{ steps.set-vars.outputs.is_latest }}
103102
is-latest-major: ${{ steps.set-vars.outputs.is_latest_major }}
@@ -147,15 +146,6 @@ jobs:
147146
fi
148147
echo "cache_key=$CACHE_KEY" >> $GITHUB_OUTPUT
149148
150-
# Compute marketplace dir (only v10 uses old path)
151-
MARKETPLACE_DIR="/var/glpi/marketplace"
152-
if [[ "$IS_SEMVER" = "true" ]]; then
153-
IMAGE_VERSION_MAJOR=$(echo "$GLPI_VERSION" | cut --delimiter=. --fields=1)
154-
if [[ "$IMAGE_VERSION_MAJOR" = "10" ]]; then
155-
MARKETPLACE_DIR="/var/www/glpi/marketplace"
156-
fi
157-
fi
158-
echo "marketplace_dir=$MARKETPLACE_DIR" >> $GITHUB_OUTPUT
159149
160150
# Compute artifact prefix (unique per workflow call)
161151
if [[ "$IMAGE_TAG" != '' ]]; then
@@ -269,7 +259,6 @@ jobs:
269259
GLPI_CACHE_KEY=${{ needs.prepare.outputs.cache-key }}
270260
BUILDER_IMAGE=php:${{ needs.prepare.outputs.php-version }}-cli-alpine
271261
APP_IMAGE=php:${{ needs.prepare.outputs.php-version }}-apache
272-
GLPI_MARKETPLACE_DIR=${{ needs.prepare.outputs.marketplace-dir }}
273262
cache-from: |
274263
type=gha,scope=${{ needs.prepare.outputs.cache-key }}-${{ matrix.platform.suffix }}
275264
type=gha,scope=main-${{ matrix.platform.suffix }}

glpi/Dockerfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ RUN /usr/src/glpi/tools/build_glpi.sh
106106
#####
107107
FROM $APP_IMAGE
108108

109-
ARG GLPI_MARKETPLACE_DIR=/var/glpi/marketplace
110109

111110
LABEL \
112111
org.opencontainers.image.title="GLPI nightly build" \
@@ -209,15 +208,27 @@ RUN a2enconf zzz-glpi.conf
209208
# Copy GLPI application.
210209
COPY --from=builder --chown=www-data:www-data /usr/src/glpi /var/www/glpi
211210

211+
# Detect GLPI major version from version/ folder and set marketplace directory
212+
# v10.x uses /var/www/glpi/marketplace, v11+ uses /var/glpi/marketplace
213+
RUN GLPI_VERSION_FILE=$(ls /var/www/glpi/version/ | sort --version-sort | tail --lines=1); \
214+
GLPI_MAJOR=$(echo "$GLPI_VERSION_FILE" | cut --delimiter='.' --fields=1); \
215+
if [ "$GLPI_MAJOR" = "10" ]; then \
216+
MARKETPLACE_DIR="/var/www/glpi/marketplace"; \
217+
else \
218+
MARKETPLACE_DIR="/var/glpi/marketplace"; \
219+
fi; \
220+
echo "GLPI_MARKETPLACE_DIR=$MARKETPLACE_DIR" >> /etc/glpi_env
221+
212222
# Declare a volume for "config", "marketplace" and "files" directory
213223
RUN mkdir /var/glpi && chown www-data:www-data /var/glpi
214224
VOLUME /var/glpi
215225

216226
# Define GLPI environment variables
227+
# Note: GLPI_MARKETPLACE_DIR is sourced from /etc/glpi_env at container startup
228+
# We cannot dynamically set an ENV value based on the output of a RUN command
217229
ENV \
218230
GLPI_INSTALL_MODE=DOCKER \
219231
GLPI_CONFIG_DIR=/var/glpi/config \
220-
GLPI_MARKETPLACE_DIR=${GLPI_MARKETPLACE_DIR} \
221232
GLPI_VAR_DIR=/var/glpi/files \
222233
GLPI_LOG_DIR=/var/glpi/logs \
223234
GLPI_SKIP_AUTOINSTALL=false \

glpi/files/opt/glpi/entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#!/bin/bash
22
set -e -u -o pipefail
33

4+
# Source GLPI environment variables (includes GLPI_MARKETPLACE_DIR detected at build time)
5+
if [ -f /etc/glpi_env ]; then
6+
export $(cat /etc/glpi_env | xargs)
7+
fi
8+
49
/opt/glpi/entrypoint/init-volumes-directories.sh
510
/opt/glpi/entrypoint/forward-logs.sh
611
/opt/glpi/entrypoint/wait-for-db.sh entrypoint

0 commit comments

Comments
 (0)