Files
devops-lib-gcp/resources/com/homelab/php-Dockerfile
T
Mukul SharmaandClaude Opus 5 6d743cbe48 Make the registry hostname configurable and drop the CA mount
buildDocker.groovy hardcoded harbor.35.238.248.203.nip.io as the push
target, so the registry could not move without editing this shared library
and every consumer moving in the same commit. It now reads
config.harbor_registry, whose default lives in homelabPipeline.groovy
beside harbor_project and every other key.

The stage errors rather than defaulting when the value is missing. Carrying
a second copy of the literal would leave two defaults free to disagree, and
an unset value would otherwise build an image named "null/<project>/<repo>"
— which docker accepts as a hostname and then fails to resolve, pointing
nowhere near the cause.

The dind pod no longer mounts the registry CA. That mount existed because
the registry was a nip.io name, which no public CA will issue for, so
cert-manager signed Harbor from a private CA; the node pool was told to
trust it for pulls, but a push comes from dockerd inside the build pod,
which has its own trust store. harbor.infra.deployshed.com carries a Let's
Encrypt certificate that both already trust, so the mount, its volume and
the whole arrangement go away rather than being repointed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LEsTefWWifp4ikvhHF5s6N
2026-09-17 09:31:32 +05:30

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.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", "."]