# Fallback only — see go-Dockerfile's header comment for the general
# rule, including the Harbor base-images sourcing (also applies here).
# Simplified from the real php-Dockerfile. Assumes a standard
# composer-based repo.
#
# Was php:*-apache (Debian, full Apache httpd) — dropped Apache
# entirely in favor of php:*-cli-alpine + PHP's own built-in dev server
# (`php -S`). Genuinely minimal (no httpd, no extra process, Alpine
# base) and brings this language in line with every other one here on
# port 8080 instead of PHP's special-cased 80. Trade-off, stated
# plainly: PHP's own docs call the built-in server "not designed to be
# a full-featured web server" for production — perfectly fine for a
# homelab/demo app, would need revisiting (php-fpm + nginx, two
# processes/containers) for anything serving real production traffic.
#
# docker-php-ext-install needs PHPIZE_DEPS present to compile
# extensions on Alpine (unlike the Debian image, which had them
# preinstalled) — installed as a virtual package and removed again
# right after, so the final image doesn't carry build tooling.
#
# NOTE ON DOLLAR SIGNS IN THIS FILE (read before editing anything
# below, comments included): the whole file — every line, comments
# included — is fed through constructTemplate.groovy's
# SimpleTemplateEngine before it becomes a real Dockerfile. That
# engine treats any dollar-sign character as the start of a Groovy
# interpolation, whether or not a human reading it would call it
# "code". A dollar sign followed by a letter or underscore gets
# looked up in the render binding (only `version` exists there) and
# throws a MissingPropertyException if not found there; a dollar sign
# followed by anything else (punctuation, space, end of line) can't
# even be parsed as an interpolation attempt and throws a harder
# syntax error instead. The only dollar sign meant to reach the shell
# below (in the PHPIZE_DEPS line) is escaped with a leading backslash
# for exactly this reason. Because a stray dollar sign in prose is
# this easy to reintroduce by accident (an earlier revision of this
# very comment did so), new edits to this header should avoid typing
# the character at all — write "dollar sign" in words instead of using
# the glyph.
FROM harbor.infra.deployshed.com/base-images/php:${version}-cli-alpine
WORKDIR /var/www/html
RUN apk add --no-cache --virtual .build-deps \$PHPIZE_DEPS \
    && docker-php-ext-install pdo pdo_mysql \
    && apk del .build-deps
COPY . .
RUN if [ -f composer.json ]; then \
      apk add --no-cache --virtual .composer-deps curl && \
      curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
      composer install --no-dev --optimize-autoloader && \
      apk del .composer-deps; \
    fi
EXPOSE 8080
CMD ["php", "-S", "0.0.0.0:8080", "-t", "."]
