-
-
Notifications
You must be signed in to change notification settings - Fork 1
perf: optimize CI workflow and Dockerfiles for faster builds #31
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,13 +30,37 @@ concurrency: | |||||||||||||||||||||||||
| cancel-in-progress: true | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||
| setup: | ||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||
| outputs: | ||||||||||||||||||||||||||
| php-versions: ${{ steps.matrix.outputs.php-versions }} | ||||||||||||||||||||||||||
| s6-version: ${{ steps.s6.outputs.version }} | ||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||
| - name: Determine PHP versions to test | ||||||||||||||||||||||||||
| id: matrix | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| if [ "${{ github.event_name }}" = "pull_request" ]; then | ||||||||||||||||||||||||||
| echo 'php-versions=["8.4","8.2"]' >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||
| echo "::notice::PR detected — testing PHP 8.4 + 8.2 only (skipping 8.3)" | ||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||
| echo 'php-versions=["8.4","8.3","8.2"]' >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
Comment on lines
+41
to
+47
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Get latest s6-overlay version | ||||||||||||||||||||||||||
| id: s6 | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| S6_OVERLAY_VERSION="$(curl -s https://api.github.com/repos/just-containers/s6-overlay/releases/latest | jq -r .tag_name)" | ||||||||||||||||||||||||||
| echo "version=${S6_OVERLAY_VERSION}" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| S6_OVERLAY_VERSION="$(curl -s https://api.github.com/repos/just-containers/s6-overlay/releases/latest | jq -r .tag_name)" | |
| echo "version=${S6_OVERLAY_VERSION}" >> $GITHUB_OUTPUT | |
| set -euo pipefail | |
| RAW_RESPONSE="$(curl -fSLs \ | |
| -H "Authorization: Bearer ${{ github.token }}" \ | |
| "https://api.github.com/repos/just-containers/s6-overlay/releases/latest")" | |
| S6_OVERLAY_VERSION="$(printf '%s\n' "${RAW_RESPONSE}" | jq -r '.tag_name')" | |
| if [ -z "${S6_OVERLAY_VERSION}" ] || [ "${S6_OVERLAY_VERSION}" = "null" ]; then | |
| echo "Error: Failed to determine latest s6-overlay version from GitHub API." >&2 | |
| exit 1 | |
| fi | |
| echo "version=${S6_OVERLAY_VERSION}" >> "$GITHUB_OUTPUT" |
Copilot
AI
Mar 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This expression references a setup output key containing a hyphen (php-versions). With dot-notation (needs.setup.outputs.php-versions) GitHub Actions can interpret this as subtraction and fail expression evaluation. Use bracket notation (needs.setup.outputs['php-versions']) or rename the output to an identifier-safe name (e.g., php_versions).
Copilot
AI
Mar 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs.setup.outputs.s6-version references an output key with a hyphen; with dot-notation this can be parsed incorrectly and break the build args. Use bracket notation (needs.setup.outputs['s6-version']) or rename the output to an identifier-safe name (e.g., s6_version).
| S6_OVERLAY_VERSION=${{ needs.setup.outputs.s6-version }} | |
| S6_OVERLAY_VERSION=${{ needs.setup.outputs['s6-version'] }} |
Copilot
AI
Mar 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue here: needs.setup.outputs.s6-version uses an output key with a hyphen, which can break expression parsing. Use bracket notation (needs.setup.outputs['s6-version']) or rename the output key.
| S6_OVERLAY_VERSION=${{ needs.setup.outputs.s6-version }} | |
| S6_OVERLAY_VERSION=${{ needs.setup.outputs['s6-version'] }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,57 +6,30 @@ ARG BASEOS | |
| # Set environment variables | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| COPY extras/retry.sh /usr/local/bin/retry | ||
| RUN chmod +x /usr/local/bin/retry | ||
|
|
||
| # Install dependencies based on the base OS | ||
| RUN if [ "$BASEOS" = "bookworm" ]; then \ | ||
| RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=apt-$BASEOS \ | ||
| --mount=type=cache,target=/var/lib/apt/lists,sharing=locked,id=aptlists-$BASEOS \ | ||
| --mount=type=cache,target=/var/cache/apk,sharing=locked,id=apk-$BASEOS \ | ||
| if [ "$BASEOS" = "bookworm" ]; then \ | ||
|
Comment on lines
+13
to
+15
|
||
| echo 'deb http://deb.debian.org/debian bookworm main' > /etc/apt/sources.list && \ | ||
| apt-get update && \ | ||
| apt-get -y upgrade && \ | ||
| apt-get install -y --no-install-recommends curl git zip unzip ghostscript imagemagick optipng gifsicle pngcrush jpegoptim libjpeg-turbo-progs pngquant webp && \ | ||
| rm -rf /var/lib/apt/lists/*; \ | ||
| apt-get install -y --no-install-recommends curl git zip unzip ghostscript imagemagick optipng gifsicle pngcrush jpegoptim libjpeg-turbo-progs pngquant webp; \ | ||
| elif [ "$BASEOS" = "alpine" ]; then \ | ||
| apk update && \ | ||
| apk add --no-cache curl git zip unzip ghostscript imagemagick optipng gifsicle pngcrush jpegoptim libjpeg-turbo libjpeg-turbo-utils pngquant libwebp-tools; \ | ||
| fi | ||
|
|
||
| # Add all needed PHP extensions with retry logic for transient network failures | ||
| RUN for ATTEMPT in 1 2 3; do \ | ||
| if curl -sSLf -o /usr/local/bin/install-php-extensions \ | ||
| https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions; then \ | ||
| break; \ | ||
| else \ | ||
| if [ $ATTEMPT -lt 3 ]; then \ | ||
| case $ATTEMPT in \ | ||
| 1) SLEEP_TIME=5 ;; \ | ||
| 2) SLEEP_TIME=10 ;; \ | ||
| esac; \ | ||
| echo "Download attempt $ATTEMPT failed, retrying in ${SLEEP_TIME}s..."; \ | ||
| sleep $SLEEP_TIME; \ | ||
| rm -f /usr/local/bin/install-php-extensions; \ | ||
| else \ | ||
| echo "Failed to download install-php-extensions after 3 attempts"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| fi; \ | ||
| done && \ | ||
| # Download and install PHP extensions with retry for transient failures | ||
| RUN retry 3 curl -sSLf -o /usr/local/bin/install-php-extensions \ | ||
| https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ | ||
| chmod +x /usr/local/bin/install-php-extensions && \ | ||
| for ATTEMPT in 1 2 3; do \ | ||
| if install-php-extensions amqp bcmath bz2 calendar ctype exif intl imagick imap json mbstring ldap mcrypt memcached mongodb \ | ||
| mysqli opcache pdo_mysql pdo_pgsql pgsql redis snmp soap sockets tidy timezonedb uuid vips xsl yaml zip zstd @composer; then \ | ||
| break; \ | ||
| else \ | ||
| if [ $ATTEMPT -lt 3 ]; then \ | ||
| case $ATTEMPT in \ | ||
| 1) SLEEP_TIME=5 ;; \ | ||
| 2) SLEEP_TIME=10 ;; \ | ||
| esac; \ | ||
| echo "Extension installation attempt $ATTEMPT failed, retrying in ${SLEEP_TIME}s..."; \ | ||
| sleep $SLEEP_TIME; \ | ||
| else \ | ||
| echo "Failed to install PHP extensions after 3 attempts"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| fi; \ | ||
| done | ||
| retry 3 install-php-extensions \ | ||
| amqp bcmath bz2 calendar ctype exif intl imagick imap json mbstring ldap mcrypt memcached mongodb \ | ||
| mysqli opcache pdo_mysql pdo_pgsql pgsql redis snmp soap sockets tidy timezonedb uuid vips xsl yaml zip zstd @composer | ||
|
|
||
| # Enable Apache rewrite mod, if applicable | ||
| RUN if command -v a2enmod; then a2enmod rewrite; fi | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -12,6 +12,9 @@ ARG VERSION | |||
| # Set environment variables | ||||
| ENV DEBIAN_FRONTEND=noninteractive | ||||
|
|
||||
| COPY extras/retry.sh /usr/local/bin/retry | ||||
| RUN chmod +x /usr/local/bin/retry | ||||
|
|
||||
| # OCI standard labels | ||||
| LABEL org.opencontainers.image.title="php-docker" \ | ||||
| org.opencontainers.image.description="PHP runtime with s6-overlay and curated extensions" \ | ||||
|
|
@@ -26,7 +29,10 @@ LABEL org.opencontainers.image.title="php-docker" \ | |||
|
|
||||
| # Install build dependencies, PHP extensions, runtime libraries, and s6-overlay | ||||
| # Then clean up build-only packages in a single layer to minimize image size | ||||
| RUN if [ "$BASEOS" = "trixie" ] || [ "$BASEOS" = "bookworm" ]; then \ | ||||
| RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=apt-$BASEOS \ | ||||
| --mount=type=cache,target=/var/lib/apt/lists,sharing=locked,id=aptlists-$BASEOS \ | ||||
| --mount=type=cache,target=/var/cache/apk,sharing=locked,id=apk-$BASEOS \ | ||||
|
||||
| --mount=type=cache,target=/var/cache/apk,sharing=locked,id=apk-$BASEOS \ |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,21 @@ | ||||||
| #!/bin/sh | ||||||
| # Retry a command with exponential backoff | ||||||
|
||||||
| # Retry a command with exponential backoff | |
| # Retry a command with linear backoff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The job output names
php-versionsands6-versioncontain hyphens, which makes them awkward/unsafe to reference via dot-notation in GitHub Actions expressions (it can be parsed as subtraction). Rename these outputs to use_(e.g.,php_versions,s6_version) or switch all references to bracket notation (e.g.,needs.setup.outputs['php-versions']).