diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..203e32e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,97 @@ +name: Build + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + matrix: + name: Load matrix + runs-on: ubuntu-latest + outputs: + include: ${{ steps.load.outputs.include }} + steps: + - uses: actions/checkout@v6 + - id: load + run: echo "include=$(jq -c . versions.json)" >> "$GITHUB_OUTPUT" + + build: + name: PHP ${{ matrix.version }} + needs: matrix + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: ${{ fromJson(needs.matrix.outputs.include) }} + steps: + - uses: actions/checkout@v6 + + # Test phase uses the default docker driver so the debug image's + # `FROM graze/php-alpine:VER` can resolve the just-built base from + # the local daemon. The docker driver is single-platform only. + - name: Build (single-arch for tests) + run: make build-${{ matrix.version }} platform=--platform=linux/amd64 + + - name: Tag + run: make tag-${{ matrix.version }} + + - name: Test + run: make test-${{ matrix.version }} + + - name: Set up QEMU + if: github.ref == 'refs/heads/master' && github.event_name == 'push' + uses: docker/setup-qemu-action@v4 + + - name: Set up Docker Buildx + if: github.ref == 'refs/heads/master' && github.event_name == 'push' + uses: docker/setup-buildx-action@v4 + + - name: Login to Docker Hub + if: github.ref == 'refs/heads/master' && github.event_name == 'push' + uses: docker/login-action@v4 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push (multi-arch) + if: github.ref == 'refs/heads/master' && github.event_name == 'push' + run: | + V="${{ matrix.version }}" + BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" + VCS_REF="$(git rev-parse --short HEAD)" + + main_tags="-t graze/php-alpine:${V}" + test_tags="-t graze/php-alpine:${V}-test" + case "$V" in + 5.6) + main_tags="$main_tags -t graze/php-alpine:5" + test_tags="$test_tags -t graze/php-alpine:5-test" + ;; + 7.4) + main_tags="$main_tags -t graze/php-alpine:7" + test_tags="$test_tags -t graze/php-alpine:7-test" + ;; + 8.5) + main_tags="$main_tags -t graze/php-alpine:8 -t graze/php-alpine:latest" + test_tags="$test_tags -t graze/php-alpine:8-test -t graze/php-alpine:test" + ;; + esac + + docker buildx build \ + --push \ + --platform=${{ matrix.platforms }} \ + --build-arg BUILD_DATE="$BUILD_DATE" \ + --build-arg VCS_REF="$VCS_REF" \ + $main_tags \ + "./$V" + + docker buildx build \ + --push \ + --platform=${{ matrix.platforms }} \ + --build-arg BUILD_DATE="$BUILD_DATE" \ + --build-arg VCS_REF="$VCS_REF" \ + -f "./$V/debug.Dockerfile" \ + $test_tags \ + "./$V" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5afd2cf..0000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -sudo: required - -language: generic - -services: - - docker - -env: - matrix: - - VER=5.6 - - VER=7.0 - - VER=7.1 - - VER=7.2 - - VER=7.3 - - VER=7.4 - - VER=8.0 - global: - # DOCKER_USERNAME - - secure: hJxx3pt08GGxbaSWKMYWXVvwlrn/sJbh4rpLveUGz5pd9C8IcvkOJsrXrtVqr7/4jb5/CQwz65cGyukxzbonvUZgt0mfmZ9GunpD1pz3IusjXvYlZOZ1LL/i6t57J7fMKtUXxBTWNQSS9pH7pEHixvMabS3kqQb74Nj6wQFNzucmnEQGCT0drs8NrlfEfaNdXkJ5ijqdY42QM0BfGU7SnO0/puaEapl3I/n1TLWf60YUV2etl8BaFZckX7ewHvLWs+nXtHUMSezO/9jupb2pOR600+/77Pdfj735hvymD/gAjzTMRJlcUAOThkQfwI4Zt4MoJKvjXbrcYYsz5yEk4o8wPRX/5lZUso2NNRR/J3ahTZZGpDxp+plwY+v6KYwC7L6Bc6HYZbDaxMMXvMokxjyyAtmewaWsVEf+VDTxg5wowJj6esfd+Z0a6IvBFiVxOzltRtR4SqLvFrjq5vPM+RHK1UStJOHCNjpDq5BrEo7bWp+Fi66LpWQYQEL15EjQy3xcx9pfY+5rHot0ClHSqror9RQmQSmmsQWZCFEcjwt07hbmwp75LjFeQm0wRAl6dBZ1CJly/6daVIv4cj7bh72McrhesXc2EmesxEbQaUd/rJjGhaoZ/joPR8gN2RLnCFPzCXdITHXWxThjUZZwPIqtJiI3xXR5vmWidV552ZA= - # DOCKER_PASSWORD - - secure: YfZCh36+apqqmIGrFx+VxhgUqNLNrAwp5BoYshJCHu0iZofVYPHxIsgauQ4vQZj/lYnqe0Ak7qG+s9vnt+OHb8rVyLaZXVRkKFFfbjuu3nOrdFgJwhFbWfjptWogoSM2X1wJtheO40oYAjegF7cq4Bxp14ux/telYCUm8mx7k/h1KoUJOzNzuZCyeh95bQPBAkzIKA1a9rupYMH/LOWLuoTCFmN0eU6VGjwK1XZoDq1uZpYk/YH8VAUvefSS2uE9/WLjoRSTJAk0A4tcVbzPN0FbDTGW59/MbqH6diZ8/KZjcALbmaNtGZGOixn0zgushSN9uSIJk9V/WKamTF08KCS79Ud1aIGYf5UtzBAycnPY2/Y7mA9Ktk/BTWui5OLk2XItY7Ts7N9ikFw+9i3e91YBxxGCVrnsLug+Ih1Ipjyu/8SN9Ttzqp2/6zBFf+sDFXTPnMpptSXTKMcXy/pJVVGIUe38L7BJdUKE1Xp4BqBVnJyaZL8UQVSKdh3kU6C/OfEud6HrIHfAKg6S71rOQBzOk+V+p/U5L4wQCJYLuyGFEuPdMP27wnLh3oUMhnkPK28EpuG0Z5RTH1Sd5MGaHThyDwEtJaECyIMndKY9Wx73gmvvwe2rrltkjHc44jyBG53B8iXNeG/kmKAqPewHHJbxC//A6ykFEnvO7tbF6To= - -script: - - make build-${VER} - - make tag-${VER} - - make test-${VER} - -deploy: - - provider: script - script: docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" && make deploy-${VER} - on: - branch: master - -matrix: - fast_finish: true diff --git a/8.1/tags.bats b/8.1/tags.bats index 19eb11e..c970acf 100644 --- a/8.1/tags.bats +++ b/8.1/tags.bats @@ -1,13 +1,13 @@ #!/usr/bin/env bats @test "the main tags are created" { - run bash -c "docker images graze/php-alpine --format '{{.ID}} ({{.Tag}})' | grep "$(docker images graze/php-alpine:8.0 --format '{{.ID}}')"" + run bash -c "docker images graze/php-alpine --format '{{.ID}} ({{.Tag}})' | grep "$(docker images graze/php-alpine:8.1 --format '{{.ID}}')"" echo 'output:' $output [[ "$output" == *"(8.1)"* ]] } @test "the test tags are created" { - run bash -c "docker images graze/php-alpine --format '{{.ID}} ({{.Tag}})' | grep "$(docker images graze/php-alpine:8.0-test --format '{{.ID}}')"" + run bash -c "docker images graze/php-alpine --format '{{.ID}} ({{.Tag}})' | grep "$(docker images graze/php-alpine:8.1-test --format '{{.ID}}')"" echo 'output:' $output [[ "$output" == *"(8.1-test)"* ]] } diff --git a/8.2/tags.bats b/8.2/tags.bats index 11f2c80..fd22ea8 100644 --- a/8.2/tags.bats +++ b/8.2/tags.bats @@ -1,13 +1,13 @@ #!/usr/bin/env bats @test "the main tags are created" { - run bash -c "docker images graze/php-alpine --format '{{.ID}} ({{.Tag}})' | grep "$(docker images graze/php-alpine:8.0 --format '{{.ID}}')"" + run bash -c "docker images graze/php-alpine --format '{{.ID}} ({{.Tag}})' | grep "$(docker images graze/php-alpine:8.2 --format '{{.ID}}')"" echo 'output:' $output [[ "$output" == *"(8.2)"* ]] } @test "the test tags are created" { - run bash -c "docker images graze/php-alpine --format '{{.ID}} ({{.Tag}})' | grep "$(docker images graze/php-alpine:8.0-test --format '{{.ID}}')"" + run bash -c "docker images graze/php-alpine --format '{{.ID}} ({{.Tag}})' | grep "$(docker images graze/php-alpine:8.2-test --format '{{.ID}}')"" echo 'output:' $output [[ "$output" == *"(8.2-test)"* ]] } diff --git a/8.3/.dockerignore b/8.3/.dockerignore new file mode 100644 index 0000000..e46b33e --- /dev/null +++ b/8.3/.dockerignore @@ -0,0 +1 @@ +*.bats diff --git a/8.3/Dockerfile b/8.3/Dockerfile new file mode 100644 index 0000000..1def43f --- /dev/null +++ b/8.3/Dockerfile @@ -0,0 +1,61 @@ +FROM php:8.3-cli-alpine3.19 + +LABEL maintainer="developers@graze.com" \ + license="MIT" \ + org.label-schema.schema-version="1.0" \ + org.label-schema.vendor="graze" \ + org.label-schema.name="php-alpine" \ + org.label-schema.description="small php image based on alpine" \ + org.label-schema.vcs-url="https://github.com/graze/docker-php-alpine" + +RUN set -xe \ + && apk add --no-cache \ + openssh-client \ + icu-libs \ + libevent \ + libmemcached-libs \ + libpq \ + libzip \ + yaml \ + && apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + icu-dev \ + libevent-dev \ + libmemcached-dev \ + libxml2-dev \ + libzip-dev \ + linux-headers \ + postgresql-dev \ + yaml-dev \ + zlib-dev \ + && docker-php-ext-install -j$(nproc) \ + bcmath \ + intl \ + mysqli \ + pcntl \ + pdo_mysql \ + pdo_pgsql \ + pgsql \ + soap \ + sockets \ + zip \ + && yes '' | pecl install apcu event memcached yaml \ + # opcache ships as a shared module on 8.3 and isn't enabled by upstream + && docker-php-ext-enable apcu memcached yaml sodium opcache \ + # event must load after sockets, hence the zz- prefix + && docker-php-ext-enable --ini-name zz-docker-php-ext-event.ini event \ + && apk del --no-network .build-deps \ + && rm -rf /tmp/pear ~/.pearrc + +COPY php/conf.d/*.ini $PHP_INI_DIR/conf.d/ + +WORKDIR /srv + +# Restore the historical empty-entrypoint behaviour of this image +ENTRYPOINT [] + +ARG BUILD_DATE +ARG VCS_REF + +LABEL org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.build-date=$BUILD_DATE diff --git a/8.3/debug.Dockerfile b/8.3/debug.Dockerfile new file mode 100644 index 0000000..1bc6a24 --- /dev/null +++ b/8.3/debug.Dockerfile @@ -0,0 +1,12 @@ +FROM graze/php-alpine:8.3 + +# The base image is built FROM php:8.3-cli-alpine which ships phpdbg as +# part of the PHP build, so no extra packages are needed for the test +# variant. This Dockerfile exists so we still produce a separate +# graze/php-alpine:8.3-test tag. + +ARG BUILD_DATE +ARG VCS_REF + +LABEL org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.build-date=$BUILD_DATE diff --git a/8.3/php.bats b/8.3/php.bats new file mode 100755 index 0000000..90b541a --- /dev/null +++ b/8.3/php.bats @@ -0,0 +1,64 @@ +#!/usr/bin/env bats + +@test "php version is correct" { + run docker run --rm ${container} php -v + echo 'status:' $status + echo 'output:' $output + version="$(echo $output | sed 's/.*PHP \([0-9].[0-9]\).*/\1/')" + echo 'version:' $version + [ "$status" -eq 0 ] + [[ "$version" == "8.3" ]] +} + +@test "the image has the correct php modules installed" { + run docker run --rm ${container} php -m + echo 'status:' $status + echo 'output:' $output + [ "$status" -eq 0 ] + [[ "${output}" == *"apcu"* ]] + [[ "${output}" == *"bcmath"* ]] + [[ "${output}" == *"Core"* ]] + [[ "${output}" == *"ctype"* ]] + [[ "${output}" == *"curl"* ]] + [[ "${output}" == *"date"* ]] + [[ "${output}" == *"dom"* ]] + [[ "${output}" == *"event"* ]] + [[ "${output}" == *"fileinfo"* ]] + [[ "${output}" == *"filter"* ]] + [[ "${output}" == *"hash"* ]] + [[ "${output}" == *"iconv"* ]] + [[ "${output}" == *"intl"* ]] + [[ "${output}" == *"json"* ]] + [[ "${output}" == *"libxml"* ]] + [[ "${output}" == *"mbstring"* ]] + [[ "${output}" == *"memcached"* ]] + [[ "${output}" == *"mysqli"* ]] + [[ "${output}" == *"mysqlnd"* ]] + [[ "${output}" == *"openssl"* ]] + [[ "${output}" == *"pcre"* ]] + [[ "${output}" == *"pcntl"* ]] + [[ "${output}" == *"PDO"* ]] + [[ "${output}" == *"pdo_mysql"* ]] + [[ "${output}" == *"pdo_pgsql"* ]] + [[ "${output}" == *"pdo_sqlite"* ]] + [[ "${output}" == *"pgsql"* ]] + [[ "${output}" == *"Phar"* ]] + [[ "${output}" == *"posix"* ]] + [[ "${output}" == *"readline"* ]] + [[ "${output}" == *"Reflection"* ]] + [[ "${output}" == *"session"* ]] + [[ "${output}" == *"SimpleXML"* ]] + [[ "${output}" == *"soap"* ]] + [[ "${output}" == *"sodium"* ]] + [[ "${output}" == *"sockets"* ]] + [[ "${output}" == *"SPL"* ]] + [[ "${output}" == *"standard"* ]] + [[ "${output}" == *"tokenizer"* ]] + [[ "${output}" == *"xml"* ]] + [[ "${output}" == *"xmlreader"* ]] + [[ "${output}" == *"xmlwriter"* ]] + [[ "${output}" == *"yaml"* ]] + [[ "${output}" == *"Zend OPcache"* ]] + [[ "${output}" == *"zip"* ]] + [[ "${output}" == *"zlib"* ]] +} diff --git a/8.3/php/conf.d/00_memlimit.ini b/8.3/php/conf.d/00_memlimit.ini new file mode 100644 index 0000000..d0c56ed --- /dev/null +++ b/8.3/php/conf.d/00_memlimit.ini @@ -0,0 +1,3 @@ +; Maximum amount of memory a script may consume (128MB) +; http://php.net/memory-limit +memory_limit = 1024M diff --git a/8.3/php/conf.d/00_short_open_tag.ini b/8.3/php/conf.d/00_short_open_tag.ini new file mode 100644 index 0000000..6f4646c --- /dev/null +++ b/8.3/php/conf.d/00_short_open_tag.ini @@ -0,0 +1,13 @@ +; This directive determines whether or not PHP will recognize code between +; tags as PHP source which should be processed as such. It's been +; recommended for several years that you not use the short tag "short cut" and +; instead to use the full tag combination. With the wide spread use +; of XML and use of these tags by other languages, the server can become easily +; confused and end up parsing the wrong code in the wrong context. But because +; this short cut has been a feature for such a long time, it's currently still +; supported for backwards compatibility, but we recommend you don't use them. +; Default Value: On +; Development Value: Off +; Production Value: Off +; http://php.net/short-open-tag +short_open_tag = On diff --git a/8.3/php_debug.bats b/8.3/php_debug.bats new file mode 100755 index 0000000..c9a8912 --- /dev/null +++ b/8.3/php_debug.bats @@ -0,0 +1,9 @@ +#!/usr/bin/env bats + +@test "the image has phpdbg" { + run docker run ${container} which phpdbg + echo 'status:' $status + echo 'output:' $output + [ "$status" -eq 0 ] + [[ "${output}" == *"phpdbg"* ]] +} diff --git a/8.3/tags.bats b/8.3/tags.bats new file mode 100644 index 0000000..d8c9c09 --- /dev/null +++ b/8.3/tags.bats @@ -0,0 +1,13 @@ +#!/usr/bin/env bats + +@test "the main tags are created" { + run bash -c "docker images graze/php-alpine --format '{{.ID}} ({{.Tag}})' | grep "$(docker images graze/php-alpine:8.3 --format '{{.ID}}')"" + echo 'output:' $output + [[ "$output" == *"(8.3)"* ]] +} + +@test "the test tags are created" { + run bash -c "docker images graze/php-alpine --format '{{.ID}} ({{.Tag}})' | grep "$(docker images graze/php-alpine:8.3-test --format '{{.ID}}')"" + echo 'output:' $output + [[ "$output" == *"(8.3-test)"* ]] +} diff --git a/8.4/.dockerignore b/8.4/.dockerignore new file mode 100644 index 0000000..e46b33e --- /dev/null +++ b/8.4/.dockerignore @@ -0,0 +1 @@ +*.bats diff --git a/8.4/Dockerfile b/8.4/Dockerfile new file mode 100644 index 0000000..1bca5ba --- /dev/null +++ b/8.4/Dockerfile @@ -0,0 +1,60 @@ +FROM php:8.4-cli-alpine3.21 + +LABEL maintainer="developers@graze.com" \ + license="MIT" \ + org.label-schema.schema-version="1.0" \ + org.label-schema.vendor="graze" \ + org.label-schema.name="php-alpine" \ + org.label-schema.description="small php image based on alpine" \ + org.label-schema.vcs-url="https://github.com/graze/docker-php-alpine" + +RUN set -xe \ + && apk add --no-cache \ + openssh-client \ + icu-libs \ + libevent \ + libmemcached-libs \ + libpq \ + libzip \ + yaml \ + && apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + icu-dev \ + libevent-dev \ + libmemcached-dev \ + libxml2-dev \ + libzip-dev \ + linux-headers \ + postgresql-dev \ + yaml-dev \ + zlib-dev \ + && docker-php-ext-install -j$(nproc) \ + bcmath \ + intl \ + mysqli \ + pcntl \ + pdo_mysql \ + pdo_pgsql \ + pgsql \ + soap \ + sockets \ + zip \ + && yes '' | pecl install apcu event memcached yaml \ + && docker-php-ext-enable apcu memcached yaml sodium \ + # event must load after sockets, hence the zz- prefix + && docker-php-ext-enable --ini-name zz-docker-php-ext-event.ini event \ + && apk del --no-network .build-deps \ + && rm -rf /tmp/pear ~/.pearrc + +COPY php/conf.d/*.ini $PHP_INI_DIR/conf.d/ + +WORKDIR /srv + +# Restore the historical empty-entrypoint behaviour of this image +ENTRYPOINT [] + +ARG BUILD_DATE +ARG VCS_REF + +LABEL org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.build-date=$BUILD_DATE diff --git a/8.4/debug.Dockerfile b/8.4/debug.Dockerfile new file mode 100644 index 0000000..c0b7eee --- /dev/null +++ b/8.4/debug.Dockerfile @@ -0,0 +1,12 @@ +FROM graze/php-alpine:8.4 + +# The base image is built FROM php:8.4-cli-alpine which ships phpdbg as +# part of the PHP build, so no extra packages are needed for the test +# variant. This Dockerfile exists so we still produce a separate +# graze/php-alpine:8.4-test tag. + +ARG BUILD_DATE +ARG VCS_REF + +LABEL org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.build-date=$BUILD_DATE diff --git a/8.4/php.bats b/8.4/php.bats new file mode 100755 index 0000000..e9db29e --- /dev/null +++ b/8.4/php.bats @@ -0,0 +1,64 @@ +#!/usr/bin/env bats + +@test "php version is correct" { + run docker run --rm ${container} php -v + echo 'status:' $status + echo 'output:' $output + version="$(echo $output | sed 's/.*PHP \([0-9].[0-9]\).*/\1/')" + echo 'version:' $version + [ "$status" -eq 0 ] + [[ "$version" == "8.4" ]] +} + +@test "the image has the correct php modules installed" { + run docker run --rm ${container} php -m + echo 'status:' $status + echo 'output:' $output + [ "$status" -eq 0 ] + [[ "${output}" == *"apcu"* ]] + [[ "${output}" == *"bcmath"* ]] + [[ "${output}" == *"Core"* ]] + [[ "${output}" == *"ctype"* ]] + [[ "${output}" == *"curl"* ]] + [[ "${output}" == *"date"* ]] + [[ "${output}" == *"dom"* ]] + [[ "${output}" == *"event"* ]] + [[ "${output}" == *"fileinfo"* ]] + [[ "${output}" == *"filter"* ]] + [[ "${output}" == *"hash"* ]] + [[ "${output}" == *"iconv"* ]] + [[ "${output}" == *"intl"* ]] + [[ "${output}" == *"json"* ]] + [[ "${output}" == *"libxml"* ]] + [[ "${output}" == *"mbstring"* ]] + [[ "${output}" == *"memcached"* ]] + [[ "${output}" == *"mysqli"* ]] + [[ "${output}" == *"mysqlnd"* ]] + [[ "${output}" == *"openssl"* ]] + [[ "${output}" == *"pcre"* ]] + [[ "${output}" == *"pcntl"* ]] + [[ "${output}" == *"PDO"* ]] + [[ "${output}" == *"pdo_mysql"* ]] + [[ "${output}" == *"pdo_pgsql"* ]] + [[ "${output}" == *"pdo_sqlite"* ]] + [[ "${output}" == *"pgsql"* ]] + [[ "${output}" == *"Phar"* ]] + [[ "${output}" == *"posix"* ]] + [[ "${output}" == *"readline"* ]] + [[ "${output}" == *"Reflection"* ]] + [[ "${output}" == *"session"* ]] + [[ "${output}" == *"SimpleXML"* ]] + [[ "${output}" == *"soap"* ]] + [[ "${output}" == *"sodium"* ]] + [[ "${output}" == *"sockets"* ]] + [[ "${output}" == *"SPL"* ]] + [[ "${output}" == *"standard"* ]] + [[ "${output}" == *"tokenizer"* ]] + [[ "${output}" == *"xml"* ]] + [[ "${output}" == *"xmlreader"* ]] + [[ "${output}" == *"xmlwriter"* ]] + [[ "${output}" == *"yaml"* ]] + [[ "${output}" == *"Zend OPcache"* ]] + [[ "${output}" == *"zip"* ]] + [[ "${output}" == *"zlib"* ]] +} diff --git a/8.4/php/conf.d/00_memlimit.ini b/8.4/php/conf.d/00_memlimit.ini new file mode 100644 index 0000000..d0c56ed --- /dev/null +++ b/8.4/php/conf.d/00_memlimit.ini @@ -0,0 +1,3 @@ +; Maximum amount of memory a script may consume (128MB) +; http://php.net/memory-limit +memory_limit = 1024M diff --git a/8.4/php/conf.d/00_short_open_tag.ini b/8.4/php/conf.d/00_short_open_tag.ini new file mode 100644 index 0000000..6f4646c --- /dev/null +++ b/8.4/php/conf.d/00_short_open_tag.ini @@ -0,0 +1,13 @@ +; This directive determines whether or not PHP will recognize code between +; tags as PHP source which should be processed as such. It's been +; recommended for several years that you not use the short tag "short cut" and +; instead to use the full tag combination. With the wide spread use +; of XML and use of these tags by other languages, the server can become easily +; confused and end up parsing the wrong code in the wrong context. But because +; this short cut has been a feature for such a long time, it's currently still +; supported for backwards compatibility, but we recommend you don't use them. +; Default Value: On +; Development Value: Off +; Production Value: Off +; http://php.net/short-open-tag +short_open_tag = On diff --git a/8.4/php_debug.bats b/8.4/php_debug.bats new file mode 100755 index 0000000..c9a8912 --- /dev/null +++ b/8.4/php_debug.bats @@ -0,0 +1,9 @@ +#!/usr/bin/env bats + +@test "the image has phpdbg" { + run docker run ${container} which phpdbg + echo 'status:' $status + echo 'output:' $output + [ "$status" -eq 0 ] + [[ "${output}" == *"phpdbg"* ]] +} diff --git a/8.4/tags.bats b/8.4/tags.bats new file mode 100644 index 0000000..20530ce --- /dev/null +++ b/8.4/tags.bats @@ -0,0 +1,13 @@ +#!/usr/bin/env bats + +@test "the main tags are created" { + run bash -c "docker images graze/php-alpine --format '{{.ID}} ({{.Tag}})' | grep "$(docker images graze/php-alpine:8.4 --format '{{.ID}}')"" + echo 'output:' $output + [[ "$output" == *"(8.4)"* ]] +} + +@test "the test tags are created" { + run bash -c "docker images graze/php-alpine --format '{{.ID}} ({{.Tag}})' | grep "$(docker images graze/php-alpine:8.4-test --format '{{.ID}}')"" + echo 'output:' $output + [[ "$output" == *"(8.4-test)"* ]] +} diff --git a/8.5/.dockerignore b/8.5/.dockerignore new file mode 100644 index 0000000..e46b33e --- /dev/null +++ b/8.5/.dockerignore @@ -0,0 +1 @@ +*.bats diff --git a/8.5/Dockerfile b/8.5/Dockerfile new file mode 100644 index 0000000..39a5edd --- /dev/null +++ b/8.5/Dockerfile @@ -0,0 +1,60 @@ +FROM php:8.5-cli-alpine3.23 + +LABEL maintainer="developers@graze.com" \ + license="MIT" \ + org.label-schema.schema-version="1.0" \ + org.label-schema.vendor="graze" \ + org.label-schema.name="php-alpine" \ + org.label-schema.description="small php image based on alpine" \ + org.label-schema.vcs-url="https://github.com/graze/docker-php-alpine" + +RUN set -xe \ + && apk add --no-cache \ + openssh-client \ + icu-libs \ + libevent \ + libmemcached-libs \ + libpq \ + libzip \ + yaml \ + && apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + icu-dev \ + libevent-dev \ + libmemcached-dev \ + libxml2-dev \ + libzip-dev \ + linux-headers \ + postgresql-dev \ + yaml-dev \ + zlib-dev \ + && docker-php-ext-install -j$(nproc) \ + bcmath \ + intl \ + mysqli \ + pcntl \ + pdo_mysql \ + pdo_pgsql \ + pgsql \ + soap \ + sockets \ + zip \ + && yes '' | pecl install apcu event memcached yaml \ + && docker-php-ext-enable apcu memcached yaml sodium \ + # event must load after sockets, hence the zz- prefix + && docker-php-ext-enable --ini-name zz-docker-php-ext-event.ini event \ + && apk del --no-network .build-deps \ + && rm -rf /tmp/pear ~/.pearrc + +COPY php/conf.d/*.ini $PHP_INI_DIR/conf.d/ + +WORKDIR /srv + +# Restore the historical empty-entrypoint behaviour of this image +ENTRYPOINT [] + +ARG BUILD_DATE +ARG VCS_REF + +LABEL org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.build-date=$BUILD_DATE diff --git a/8.5/debug.Dockerfile b/8.5/debug.Dockerfile new file mode 100644 index 0000000..5312193 --- /dev/null +++ b/8.5/debug.Dockerfile @@ -0,0 +1,12 @@ +FROM graze/php-alpine:8.5 + +# The base image is built FROM php:8.5-cli-alpine which ships phpdbg as +# part of the PHP build, so no extra packages are needed for the test +# variant. This Dockerfile exists so we still produce a separate +# graze/php-alpine:8.5-test tag. + +ARG BUILD_DATE +ARG VCS_REF + +LABEL org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.build-date=$BUILD_DATE diff --git a/8.5/php.bats b/8.5/php.bats new file mode 100755 index 0000000..513d006 --- /dev/null +++ b/8.5/php.bats @@ -0,0 +1,64 @@ +#!/usr/bin/env bats + +@test "php version is correct" { + run docker run --rm ${container} php -v + echo 'status:' $status + echo 'output:' $output + version="$(echo $output | sed 's/.*PHP \([0-9].[0-9]\).*/\1/')" + echo 'version:' $version + [ "$status" -eq 0 ] + [[ "$version" == "8.5" ]] +} + +@test "the image has the correct php modules installed" { + run docker run --rm ${container} php -m + echo 'status:' $status + echo 'output:' $output + [ "$status" -eq 0 ] + [[ "${output}" == *"apcu"* ]] + [[ "${output}" == *"bcmath"* ]] + [[ "${output}" == *"Core"* ]] + [[ "${output}" == *"ctype"* ]] + [[ "${output}" == *"curl"* ]] + [[ "${output}" == *"date"* ]] + [[ "${output}" == *"dom"* ]] + [[ "${output}" == *"event"* ]] + [[ "${output}" == *"fileinfo"* ]] + [[ "${output}" == *"filter"* ]] + [[ "${output}" == *"hash"* ]] + [[ "${output}" == *"iconv"* ]] + [[ "${output}" == *"intl"* ]] + [[ "${output}" == *"json"* ]] + [[ "${output}" == *"libxml"* ]] + [[ "${output}" == *"mbstring"* ]] + [[ "${output}" == *"memcached"* ]] + [[ "${output}" == *"mysqli"* ]] + [[ "${output}" == *"mysqlnd"* ]] + [[ "${output}" == *"openssl"* ]] + [[ "${output}" == *"pcre"* ]] + [[ "${output}" == *"pcntl"* ]] + [[ "${output}" == *"PDO"* ]] + [[ "${output}" == *"pdo_mysql"* ]] + [[ "${output}" == *"pdo_pgsql"* ]] + [[ "${output}" == *"pdo_sqlite"* ]] + [[ "${output}" == *"pgsql"* ]] + [[ "${output}" == *"Phar"* ]] + [[ "${output}" == *"posix"* ]] + [[ "${output}" == *"readline"* ]] + [[ "${output}" == *"Reflection"* ]] + [[ "${output}" == *"session"* ]] + [[ "${output}" == *"SimpleXML"* ]] + [[ "${output}" == *"soap"* ]] + [[ "${output}" == *"sodium"* ]] + [[ "${output}" == *"sockets"* ]] + [[ "${output}" == *"SPL"* ]] + [[ "${output}" == *"standard"* ]] + [[ "${output}" == *"tokenizer"* ]] + [[ "${output}" == *"xml"* ]] + [[ "${output}" == *"xmlreader"* ]] + [[ "${output}" == *"xmlwriter"* ]] + [[ "${output}" == *"yaml"* ]] + [[ "${output}" == *"Zend OPcache"* ]] + [[ "${output}" == *"zip"* ]] + [[ "${output}" == *"zlib"* ]] +} diff --git a/8.5/php/conf.d/00_memlimit.ini b/8.5/php/conf.d/00_memlimit.ini new file mode 100644 index 0000000..d0c56ed --- /dev/null +++ b/8.5/php/conf.d/00_memlimit.ini @@ -0,0 +1,3 @@ +; Maximum amount of memory a script may consume (128MB) +; http://php.net/memory-limit +memory_limit = 1024M diff --git a/8.5/php/conf.d/00_short_open_tag.ini b/8.5/php/conf.d/00_short_open_tag.ini new file mode 100644 index 0000000..6f4646c --- /dev/null +++ b/8.5/php/conf.d/00_short_open_tag.ini @@ -0,0 +1,13 @@ +; This directive determines whether or not PHP will recognize code between +; tags as PHP source which should be processed as such. It's been +; recommended for several years that you not use the short tag "short cut" and +; instead to use the full tag combination. With the wide spread use +; of XML and use of these tags by other languages, the server can become easily +; confused and end up parsing the wrong code in the wrong context. But because +; this short cut has been a feature for such a long time, it's currently still +; supported for backwards compatibility, but we recommend you don't use them. +; Default Value: On +; Development Value: Off +; Production Value: Off +; http://php.net/short-open-tag +short_open_tag = On diff --git a/8.5/php_debug.bats b/8.5/php_debug.bats new file mode 100755 index 0000000..c9a8912 --- /dev/null +++ b/8.5/php_debug.bats @@ -0,0 +1,9 @@ +#!/usr/bin/env bats + +@test "the image has phpdbg" { + run docker run ${container} which phpdbg + echo 'status:' $status + echo 'output:' $output + [ "$status" -eq 0 ] + [[ "${output}" == *"phpdbg"* ]] +} diff --git a/8.5/tags.bats b/8.5/tags.bats new file mode 100644 index 0000000..1ab4426 --- /dev/null +++ b/8.5/tags.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats + +@test "the main tags are created" { + run bash -c "docker images graze/php-alpine --format '{{.ID}} ({{.Tag}})' | grep "$(docker images graze/php-alpine:8.5 --format '{{.ID}}')"" + echo 'output:' $output + [[ "$output" == *"(8.5)"* ]] + [[ "$output" == *"(8)"* ]] + [[ "$output" == *"(latest)"* ]] +} + +@test "the test tags are created" { + run bash -c "docker images graze/php-alpine --format '{{.ID}} ({{.Tag}})' | grep "$(docker images graze/php-alpine:8.5-test --format '{{.ID}}')"" + echo 'output:' $output + [[ "$output" == *"(8.5-test)"* ]] + [[ "$output" == *"(8-test)"* ]] + [[ "$output" == *"(test)"* ]] +} diff --git a/Makefile b/Makefile index 1fbf1a8..14092f7 100644 --- a/Makefile +++ b/Makefile @@ -11,15 +11,20 @@ docker_bats := docker run --rm \ --platform linux/${PLATFORM} \ -v $$(pwd):/app -v /var/run/docker.sock:/var/run/docker.sock \ -e container \ + -e GIT_CONFIG_COUNT=1 \ + -e GIT_CONFIG_KEY_0=safe.directory \ + -e GIT_CONFIG_VALUE_0=/app \ graze/bats build_args := --build-arg BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") \ --build-arg VCS_REF=$(shell git rev-parse --short HEAD) +VERSIONS := $(shell jq -r '.[].version' versions.json) + latest_5 := 5.6 latest_7 := 7.4 -latest_8 := 8.2 -latest := 8.2 +latest_8 := 8.5 +latest := 8.5 .PHONY: build build-quick .PHONY: tag @@ -30,25 +35,25 @@ latest := 8.2 .PHONY: prod-build prod-build-quick .DEFAULT: build -build: build-5.6 build-7.0 build-7.1 build-7.2 build-7.3 build-7.4 build-8.0 build-8.1 build-8.2 +build: $(addprefix build-,$(VERSIONS)) build-quick: make build cache="" pull="" build-quick-%: make build-$* cache="" pull="" -prod-build: prod-build-5.6 prod-build-7.0 prod-build-7.1 prod-build-7.2 prod-build-7.3 prod-build-7.4 prod-build-8.0 prod-build-8.1 prod-build-8.2 +prod-build: $(addprefix prod-build-,$(VERSIONS)) prod-build-quick: make prod-build cache="" pull="" prod-build-quick-%: make prod-build-$* cache="" pull="" -tag: tag-5.6 tag-7.0 tag-7.1 tag-7.2 tag-7.3 tag-7.4 tag-8.0 tag-8.1 test-8.2 -test: test-5.6 test-7.0 test-7.1 test-7.2 test-7.3 test-7.4 test-8.0 test-8.1 test-8.2 -push: push-5.6 push-7.0 push-7.1 push-7.2 push-7.3 push-7.4 push-8.0 push-8.1 push-8.2 -clean: clean-5.6 clean-7.0 clean-7.1 clean-7.2 clean-7.3 clean-7.4 clean-8.0 clean-8.1 clean-8.2 -deploy: deploy-5.6 deploy-7.0 deploy-7.1 deploy-7.2 deploy-7.3 deploy-7.4 deploy-8.0 deploy-8.1 deploy-8.2 +tag: $(addprefix tag-,$(VERSIONS)) +test: $(addprefix test-,$(VERSIONS)) +push: $(addprefix push-,$(VERSIONS)) +clean: $(addprefix clean-,$(VERSIONS)) +deploy: $(addprefix deploy-,$(VERSIONS)) build-%: cache ?= --no-cache build-%: pull ?= --pull diff --git a/README.md b/README.md index e6c9f0c..bab3fdc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PHP Alpine Base Images -[![Build Status](https://img.shields.io/travis/graze/docker-php-alpine/master.svg)](https://travis-ci.org/graze/docker-php-alpine) +[![Build Status](https://github.com/graze/docker-php-alpine/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/graze/docker-php-alpine/actions/workflows/build.yml) [![Docker Pulls](https://img.shields.io/docker/pulls/graze/php-alpine.svg)](https://hub.docker.com/r/graze/php-alpine/) [![Image Size](https://images.microbadger.com/badges/image/graze/php-alpine.svg)](https://microbadger.com/images/graze/php-alpine) @@ -8,7 +8,12 @@ Public image for php in alpine with a set of common extensions ## Images -- `8.0`, `8`, `latest` [8.0/Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/8.0/Dockerfile) +- `8.5`, `8`, `latest` [8.5/Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/8.5/Dockerfile) +- `8.4` [8.4/Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/8.4/Dockerfile) +- `8.3` [8.3/Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/8.3/Dockerfile) +- `8.2` [8.2/Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/8.2/Dockerfile) +- `8.1` [8.1/Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/8.1/Dockerfile) +- `8.0` [8.0/Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/8.0/Dockerfile) - `7.4`, `7` [7.4/Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/7.4/Dockerfile) - `7.3` [7.3/Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/7.3/Dockerfile) - `7.2` [7.2/Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/7.2/Dockerfile) @@ -21,7 +26,7 @@ Public image for php in alpine with a set of common extensions [apcu](http://php.net/manual/en/book.apcu.php) (PHP 7.0 +), [bcmath](http://php.net/manual/en/book.bc.php), Core, [ctype](http://php.net/manual/en/book.ctype.php), [curl](http://php.net/manual/en/book.curl.php), [date](http://php.net/manual/en/book.datetime.php), [dom](http://php.net/manual/en/book.dom.php), -[ev](http://php.net/manual/en/book.ev.php), [fileinfo](http://php.net/manual/en/book.fileinfo.php), +[event](http://php.net/manual/en/book.event.php), [fileinfo](http://php.net/manual/en/book.fileinfo.php), [filter](http://php.net/manual/en/book.filter.php), [hash](http://php.net/manual/en/book.hash.php), [iconv](http://php.net/manual/en/book.iconv.php) (with a [fix](https://github.com/docker-library/php/issues/240)), [intl](http://php.net/manual/en/book.intl.php), [json](http://php.net/manual/en/book.json.php), @@ -45,7 +50,12 @@ standard, [tokenizer](http://php.net/manual/en/book.tokenizer.php), [xml](http:/ Testing images are the same as the standard, but with xdebug (php 5.6) or phpdbg (php 7.* and 8.*) -- `8.0-test`, `8-test`, `test` [8.0/debug.Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/8.0/debug.Dockerfile) +- `8.5-test`, `8-test`, `test` [8.5/debug.Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/8.5/debug.Dockerfile) +- `8.4-test` [8.4/debug.Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/8.4/debug.Dockerfile) +- `8.3-test` [8.3/debug.Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/8.3/debug.Dockerfile) +- `8.2-test` [8.2/debug.Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/8.2/debug.Dockerfile) +- `8.1-test` [8.1/debug.Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/8.1/debug.Dockerfile) +- `8.0-test` [8.0/debug.Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/8.0/debug.Dockerfile) - `7.4-test`, `7-test` [7.4/debug.Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/7.4/debug.Dockerfile) - `7.3-test` [7.3/debug.Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/7.3/debug.Dockerfile) - `7.2-test` [7.2/debug.Dockerfile](https://github.com/graze/docker-php-alpine/blob/master/7.2/debug.Dockerfile) @@ -79,6 +89,6 @@ docker run --rm graze/php-alpine -v $(pwd):/srv php some/script.php ## Running with phpdbg ``` -docker run --rm graze/php-alpine:test -v $(pwd):/srv phpdbg7 some/script.php +docker run --rm graze/php-alpine:test -v $(pwd):/srv phpdbg some/script.php ``` diff --git a/common/php.bats b/common/php.bats index 9bdbfd1..4dbe730 100755 --- a/common/php.bats +++ b/common/php.bats @@ -82,28 +82,26 @@ } @test "php should have a memory limit of 1024M" { - run bash -c "docker run --rm ${container} php -i | grep memory_limit" + run bash -c "docker run --rm ${container} php -i | grep -w memory_limit" echo "status: $status" echo "output: $output" [ "$status" -eq 0 ] [ "$output" = "memory_limit => 1024M => 1024M" ] } -@test "the image uses a fixed iconv module" { - run bash -c "docker inspect ${container} | jq -r '.[]?.Config.Env[]'" +@test "iconv //TRANSLIT works" { + run docker run ${container} php -r 'echo iconv("UTF-8", "ASCII//TRANSLIT", "café");' echo "status: $status" echo "output: $output" [ "$status" -eq 0 ] - [[ "${output}" == *"LD_PRELOAD=/usr/lib/preloadable_libiconv.so php"* ]] -} - -@test "iconv works" { - run docker run ${container} php -r 'echo iconv("UTF-8", "ASCII//TRANSLIT", "foobar");' - echo "status: $status" - echo "output: $output" - [ "$status" -eq 0 ] - [ "$output" = "foobar" ] + # gnu-libiconv's transliteration of 'é' varies across versions ("caf'e" + # in 1.15-r3, "cafe" in 1.18+). Both are valid; what we care about is + # that TRANSLIT didn't fall back to musl's iconv (which would warn and + # return the original byte sequence). + [[ "${output}" != *"PHP Warning"* ]] [[ "${output}" != *"PHP Notice"* ]] + [[ "${output}" == caf* ]] + [ "${output}" != "café" ] } @test "the image has curl installed" { diff --git a/versions.json b/versions.json new file mode 100644 index 0000000..17642f8 --- /dev/null +++ b/versions.json @@ -0,0 +1,14 @@ +[ + {"version": "5.6", "platforms": "linux/amd64"}, + {"version": "7.0", "platforms": "linux/amd64"}, + {"version": "7.1", "platforms": "linux/amd64"}, + {"version": "7.2", "platforms": "linux/amd64"}, + {"version": "7.3", "platforms": "linux/amd64,linux/arm/v7,linux/arm64"}, + {"version": "7.4", "platforms": "linux/amd64,linux/arm/v7,linux/arm64"}, + {"version": "8.0", "platforms": "linux/amd64,linux/arm/v7,linux/arm64"}, + {"version": "8.1", "platforms": "linux/amd64,linux/arm/v7,linux/arm64"}, + {"version": "8.2", "platforms": "linux/amd64,linux/arm/v7,linux/arm64"}, + {"version": "8.3", "platforms": "linux/amd64,linux/arm/v7,linux/arm64"}, + {"version": "8.4", "platforms": "linux/amd64,linux/arm/v7,linux/arm64"}, + {"version": "8.5", "platforms": "linux/amd64,linux/arm/v7,linux/arm64"} +]