Skip to content
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

php: Simplify the end-user installation with a helper script #3

Merged
merged 1 commit into from
May 16, 2024
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
38 changes: 25 additions & 13 deletions php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,35 @@ FROM debian:bookworm-slim

LABEL org.opencontainers.image.source="https://github.com/tideways/container-images"

RUN set -eux; \
export DEBIAN_FRONTEND="noninteractive"; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
; \
rm -rf /var/lib/apt/lists/*

COPY tideways.asc /usr/share/keyrings/tideways.asc
COPY --chmod=0755 get-ext-path.php /tideways/

ENV TIDEWAYS_PHP_VERSION 5.9.0
ENV TIDEWAYS_PHP_SHA256_X64 cbadbc49558ece142ec431b3c1291c5374e081c25345877f31aedcb9ee2e78f6
ENV TIDEWAYS_PHP_SHA256_ARM64 42f76a2ecb2f9f545570e81c8623d0cf2e72e78a6b0b90a434cbeaba6c9a5227

RUN set -eux; \
export DEBIAN_FRONTEND="noninteractive"; \
echo 'deb [signed-by=/usr/share/keyrings/tideways.asc] https://packages.tideways.com/apt-packages-main any-version main' |tee /etc/apt/sources.list.d/tideways.list; \
buildDeps='curl ca-certificates'; \
apt-get update; \
apt-get install -y \
tideways-php=$TIDEWAYS_PHP_VERSION \
apt-get install -y --no-install-recommends \
$buildDeps \
; \
rm -rf /var/lib/apt/lists/*
\
dpkgArch="$(dpkg --print-architecture)"; \
case "$dpkgArch" in \
arm64) arch='arm64' checksum="$TIDEWAYS_PHP_SHA256_ARM64" ;; \
amd64) arch='x86_64' checksum="$TIDEWAYS_PHP_SHA256_X64" ;; \
*) echo >&2 "error: unsupported architecture: $dpkgArch"; exit 1 ;; \
esac; \
\
curl -fsSL "https://tideways.s3.amazonaws.com/extension/${TIDEWAYS_PHP_VERSION}/tideways-php-${TIDEWAYS_PHP_VERSION}-${arch}.tar.gz" -o tideways-php.tar.gz; \
echo "$checksum *tideways-php.tar.gz" |sha256sum -c; \
mkdir -p /tmp/tideways/; \
tar xvf tideways-php.tar.gz --strip-components=1 -C /tmp/tideways/; \
cp /tmp/tideways/*.so /tideways/; \
\
rm -r /tmp/tideways/; \
rm tideways-php.tar.gz; \
apt-get purge -y --auto-remove \
$buildDeps; \
rm -rf /var/lib/apt/lists/*;
11 changes: 9 additions & 2 deletions php/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ FROM alpine:3.19

LABEL org.opencontainers.image.source="https://github.com/tideways/container-images"

COPY --chmod=0755 get-ext-path.php /tideways/

ENV TIDEWAYS_PHP_VERSION 5.9.0
ENV TIDEWAYS_PHP_SHA256_X64 7fcec20e09c1b6753d949c5159a03b21249220d333725d82a0758061479fe22c
ENV TIDEWAYS_PHP_SHA256_ARM64 2bbf1214215c9b3d1e589ef87371ad3a17465702f014a311be56ad23f384eab7
Expand All @@ -10,15 +12,20 @@ RUN set -eux; \
apk add --no-cache --virtual .build-deps \
curl \
; \
\
apkArch="$(apk --print-arch)"; \
case "$apkArch" in \
aarch64) arch='arm64' checksum="$TIDEWAYS_PHP_SHA256_ARM64" ;; \
x86_64) arch='x86_64' checksum="$TIDEWAYS_PHP_SHA256_X64" ;; \
*) echo >&2 "error: unsupported architecture: $apkArch"; exit 1 ;; \
esac; \
\
curl -fsSL "https://tideways.s3.amazonaws.com/extension/${TIDEWAYS_PHP_VERSION}/tideways-php-${TIDEWAYS_PHP_VERSION}-alpine-${arch}.tar.gz" -o tideways-php-alpine.tar.gz; \
echo "$checksum *tideways-php-alpine.tar.gz" |sha256sum -c; \
mkdir -p /usr/lib/tideways/; \
tar xvf tideways-php-alpine.tar.gz --strip-components=1 -C /usr/lib/tideways/; \
mkdir -p /tmp/tideways/; \
tar xvf tideways-php-alpine.tar.gz --strip-components=1 -C /tmp/tideways/; \
cp /tmp/tideways/*.so /tideways/; \
\
rm -r /tmp/tideways/; \
rm tideways-php-alpine.tar.gz; \
apk del --no-network .build-deps;
18 changes: 18 additions & 0 deletions php/alpine/get-ext-path.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env php
<?php

$fullPath = sprintf(
"%s/tideways-php%s-%d.%d%s.so",
__DIR__,
file_exists("/lib/apk/db/installed") ? "-alpine" : "",
PHP_MAJOR_VERSION,
PHP_MINOR_VERSION,
PHP_ZTS ? "-zts" : ""
);

if (!\is_file($fullPath)) {
fwrite(STDERR, "Unable to determine extension path: $fullPath");
exit(1);
}

echo $fullPath;
18 changes: 18 additions & 0 deletions php/get-ext-path.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env php
<?php

$fullPath = sprintf(
"%s/tideways-php%s-%d.%d%s.so",
__DIR__,
file_exists("/lib/apk/db/installed") ? "-alpine" : "",
PHP_MAJOR_VERSION,
PHP_MINOR_VERSION,
PHP_ZTS ? "-zts" : ""
);

if (!\is_file($fullPath)) {
fwrite(STDERR, "Unable to determine extension path: $fullPath");
exit(1);
}

echo $fullPath;
4 changes: 4 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ mv -f daemon/Dockerfile.new daemon/Dockerfile
TIDEWAYS_PHP_VERSION="$(echo "$versions" |jq -r '.php.version')"
awk \
-v "TIDEWAYS_PHP_VERSION=$TIDEWAYS_PHP_VERSION" \
-v "TIDEWAYS_PHP_SHA256_X64=$(curl -fsSL "https://tideways.s3.amazonaws.com/extension/${TIDEWAYS_PHP_VERSION}/tideways-php-${TIDEWAYS_PHP_VERSION}-x86_64.tar.gz" |sha256sum |cut -d' ' -f1)" \
-v "TIDEWAYS_PHP_SHA256_ARM64=$(curl -fsSL "https://tideways.s3.amazonaws.com/extension/${TIDEWAYS_PHP_VERSION}/tideways-php-${TIDEWAYS_PHP_VERSION}-arm64.tar.gz" |sha256sum |cut -d' ' -f1)" \
' \
$1 == "ENV" && $2 == "TIDEWAYS_PHP_VERSION"{$3 = TIDEWAYS_PHP_VERSION}
$1 == "ENV" && $2 == "TIDEWAYS_PHP_SHA256_X64"{$3 = TIDEWAYS_PHP_SHA256_X64} \
$1 == "ENV" && $2 == "TIDEWAYS_PHP_SHA256_ARM64"{$3 = TIDEWAYS_PHP_SHA256_ARM64} \
{print} \
' \
< php/Dockerfile > php/Dockerfile.new
Expand Down