The previous fix (47a60b7) escaped the functional \$PHPIZE_DEPS
reference but added an explanatory comment that itself used several
bare/example $ characters (${PHPIZE_DEPS}, $PHPIZE_DEPS, $IDENTIFIER,
${IDENTIFIER}, and a bare $ before a comma). SimpleTemplateEngine
parses the ENTIRE file as template source, comments included, so any
of those threw either MissingPropertyException or a harder
'illegal string body character after dollar sign' parse error
depending on what followed the $.
Rewrote the comment to explain the rule in prose without using the $
glyph as an illustrative example at all, so future edits to the
comment can't reintroduce this. Verified via grep across all five
fallback Dockerfiles that the only remaining $ occurrences are the
intentional ${version} placeholders plus the one properly-escaped
\$PHPIZE_DEPS.
53 lines
2.8 KiB
Plaintext
53 lines
2.8 KiB
Plaintext
# 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.192.168.1.7.nip.io/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", "."]
|