Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ FROM composer:${COMPOSER_VERSION} AS composer

FROM php:${PHP_VERSION}-cli

# Mago version to install. Keep in sync with the central `mago.toml`
# `version =` pin in webware/webware-tools.
ARG MAGO_VERSION=1.47.3

# ---------------------------------------------------------------------------
# System packages + PHP extensions
# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -77,23 +73,44 @@ RUN set -eux; \
COPY --from=composer /usr/bin/composer /usr/bin/composer

# ---------------------------------------------------------------------------
# Mago (statically linked Rust binary). Select the correct release asset for
# the build target architecture so the same Dockerfile works on x86_64 and
# arm64 hosts.
# Mago (statically linked Rust binary).
#
# The version is NOT pinned in this file. It is read from the `version =` pin in
# webware/webware-tools/mago.toml, resolved at the exact revision this
# repository's composer.lock requires -- so the tool inside the container always
# matches the pin the package's own config (which `extends` the centre
# mago.toml) enforces. That pin has exactly one home: webware/webware-tools.
#
# The release asset is selected for the build target architecture so the same
# Dockerfile works on x86_64 and arm64 hosts.
# ---------------------------------------------------------------------------
COPY composer.lock /tmp/composer.lock
ARG TARGETARCH
RUN set -eux; \
case "${TARGETARCH}" in \
amd64) MAGO_TRIPLE="x86_64-unknown-linux-gnu" ;; \
arm64) MAGO_TRIPLE="aarch64-unknown-linux-gnu" ;; \
*) echo "unsupported TARGETARCH: ${TARGETARCH}" >&2; exit 1 ;; \
esac; \
WEBWARE_TOOLS_REV="$(php -r '$lock = json_decode(file_get_contents("/tmp/composer.lock"), true, 512, JSON_THROW_ON_ERROR); foreach (array_merge($lock["packages"] ?? [], $lock["packages-dev"] ?? []) as $package) { if (($package["name"] ?? "") === "webware/webware-tools") { echo $package["source"]["reference"] ?? ""; break; } }')"; \
if [ -z "${WEBWARE_TOOLS_REV}" ]; then \
echo "composer.lock does not pin webware/webware-tools" >&2; \
exit 1; \
fi; \
curl -fsSL \
"https://raw.githubusercontent.com/webinertia/webware-tools/${WEBWARE_TOOLS_REV}/mago.toml" \
-o /tmp/webware-tools-mago.toml; \
MAGO_VERSION="$(sed -nE 's/^[[:space:]]*version[[:space:]]*=[[:space:]]*"([0-9]+\.[0-9]+\.[0-9]+)".*/\1/p' /tmp/webware-tools-mago.toml | head -n1)"; \
if [ -z "${MAGO_VERSION}" ]; then \
echo "no version pin in webware-tools/mago.toml at ${WEBWARE_TOOLS_REV}" >&2; \
exit 1; \
fi; \
curl -fsSL \
"https://github.com/carthage-software/mago/releases/download/${MAGO_VERSION}/mago-${MAGO_VERSION}-${MAGO_TRIPLE}.tar.gz" \
-o /tmp/mago.tar.gz; \
tar -xzf /tmp/mago.tar.gz -C /tmp; \
install -m 0755 "/tmp/mago-${MAGO_VERSION}-${MAGO_TRIPLE}/mago" /usr/local/bin/mago; \
rm -rf /tmp/mago.tar.gz "/tmp/mago-${MAGO_VERSION}-${MAGO_TRIPLE}"; \
rm -rf /tmp/mago.tar.gz "/tmp/mago-${MAGO_VERSION}-${MAGO_TRIPLE}" /tmp/composer.lock /tmp/webware-tools-mago.toml; \
mago --version

WORKDIR /app
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![PHP Version](https://img.shields.io/packagist/php-v/webware/webware-admin)](https://packagist.org/packages/webware/webware-admin)
[![Latest Version](https://img.shields.io/packagist/v/webware/webware-admin)](https://packagist.org/packages/webware/webware-admin)
[![License](https://img.shields.io/github/license/webinertia/webware-admin)](LICENSE)
[![Continuous Integration](https://github.com/webinertia/webware-admin/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/webinertia/webware-admin/actions/workflows/continuous-integration.yml)
[![Required CI](https://github.com/webinertia/webware-admin/actions/workflows/required/webinertia/.github/.github/workflows/org-required-ci.yml/badge.svg)](https://github.com/webinertia/webware-admin/actions/workflows/required/webinertia/.github/.github/workflows/org-required-ci.yml)
[![codecov](https://codecov.io/gh/webinertia/webware-admin/graph/badge.svg)](https://codecov.io/gh/webinertia/webware-admin)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fwebinertia%2Fwebware-admin%2F0.1.x)](https://dashboard.stryker-mutator.io/reports/github.com/webinertia/webware-admin/0.1.x)

Expand Down
3 changes: 0 additions & 3 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ services:
# in sync with the package's supported PHP versions and
# `config.platform.php`.
PHP_VERSION: "8.4.24"
# Keep in sync with the central mago.toml `version =` pin in
# webware/webware-tools.
MAGO_VERSION: "1.47.3"
# Keep the container alive so `docker compose exec` can attach to it.
# (VS Code Dev Containers override this with their own command.)
command: sleep infinity
Expand Down
Loading