diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..2c7d170 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0dc7465..ed6e31f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,173 +10,155 @@ name: build # When to run # ------------------------------------------------------------------------------------------------- on: - # Runs on Pull Requests - pull_request: # Runs on Push push: -# ------------------------------------------------------------------------------------------------- -# What to run -# ------------------------------------------------------------------------------------------------- jobs: + + # ----------------------------------------------------------------------------------------------- + # Job (1/2): BUILD + # ----------------------------------------------------------------------------------------------- build: - name: "[ PHP-${{ matrix.version }} ]" + name: "[ PHP-${{ matrix.version }} (${{ matrix.arch }}) ]" runs-on: ubuntu-latest strategy: - fail-fast: False + fail-fast: false matrix: version: - '5.3' + arch: + - 'linux/amd64' + - 'linux/arm64' + - 'linux/386' + - 'linux/arm/v7' + - 'linux/arm/v6' steps: # ------------------------------------------------------------ # Setup repository # ------------------------------------------------------------ - - name: Checkout repository + - name: "[SETUP] Checkout repository" uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set variables - id: vars - run: | - - # Retrieve git info (tags, etc) - git fetch --all - - # Branch, Tag or Commit - GIT_TYPE="$( \ - curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \ - | sh \ - | grep '^GIT_TYPE' \ - | sed 's|.*=||g' \ - )" - # Branch name, Tag name or Commit Hash - GIT_SLUG="$( \ - curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \ - | sh \ - | grep '^GIT_NAME' \ - | sed 's|.*=||g' \ - )" - # Docker Tag - if [ "${GIT_TYPE}" = "BRANCH" ] && [ "${GIT_SLUG}" = "master" ]; then - DOCKER_TAG="latest" - else - DOCKER_TAG="${GIT_SLUG}" - fi - - # Output - echo "GIT_TYPE=${GIT_TYPE}" - echo "GIT_SLUG=${GIT_SLUG}" - echo "DOCKER_TAG=${DOCKER_TAG}" - - # Export variable - # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files - echo "GIT_TYPE=${GIT_TYPE}" >> ${GITHUB_ENV} - echo "GIT_SLUG=${GIT_SLUG}" >> ${GITHUB_ENV} - echo "DOCKER_TAG=${DOCKER_TAG}" >> ${GITHUB_ENV} + - name: "[SETUP] Setup QEMU environment" + uses: docker/setup-qemu-action@v1 + with: + image: tonistiigi/binfmt:latest + platforms: all + - name: "[SETUP] Determine Docker tag" + id: tag + uses: cytopia/docker-tag@v0.3 # ------------------------------------------------------------ # Build # ------------------------------------------------------------ - name: Build - run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make build ARCH=${ARCH} env: - RETRIES: 20 - PAUSE: 10 + ARCH: ${{ matrix.arch }} # ------------------------------------------------------------ # Test # ------------------------------------------------------------ - - name: Test Docker Image - run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test + - name: "[TEST] Docker Image" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make test ARCH=${ARCH} + env: + ARCH: ${{ matrix.arch }} + + - name: "[TEST] Update README" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make update-readme ARCH=${ARCH} env: - RETRIES: 20 - PAUSE: 10 + ARCH: ${{ matrix.arch }} - - name: Test Repository Readme + - name: "[TEST] Verify README" run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make update-readme git diff --quiet || { echo "Build Changes"; git diff; git status; false; } + + # ------------------------------------------------------------ + # Deploy + # ------------------------------------------------------------ + - name: "[DEPLOY] Login" + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: "[DEPLOY] Publish architecture image (only repo owner)" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make push-arch TAG=${{ steps.tag.outputs.docker-tag }} ARCH=${ARCH} env: - RETRIES: 20 - PAUSE: 10 + ARCH: ${{ matrix.arch }} + # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions + if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id + && ( + (github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) + || + (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) + || + (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-')) + ) + + # ----------------------------------------------------------------------------------------------- + # Job (2/2): DEPLOY + # ----------------------------------------------------------------------------------------------- + deploy: + needs: [build] + name: Deploy + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + version: + - '5.3' + steps: + + # ------------------------------------------------------------ + # Setup repository + # ------------------------------------------------------------ + - name: "[SETUP] Checkout repository" + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: "[SETUP] Determine Docker tag" + id: tag + uses: cytopia/docker-tag@v0.3 # ------------------------------------------------------------ # Deploy # ------------------------------------------------------------ - - name: Publish images (only repo owner) - run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - - # Output - echo "GIT_TYPE=${GIT_TYPE}" - echo "GIT_SLUG=${GIT_SLUG}" - echo "DOCKER_TAG=${DOCKER_TAG}" - - # Tag image - retry make tag TAG=${DOCKER_TAG} - docker images - - # Login and Push - retry make login USER=${{ secrets.DOCKERHUB_USERNAME }} PASS=${{ secrets.DOCKERHUB_PASSWORD }} - retry make push TAG=${DOCKER_TAG} + - name: "[DEPLOY] Login" + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} - env: - RETRIES: 20 - PAUSE: 10 + - name: "[DEPLOY] Create Docker manifest" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make manifest-create TAG=${{ steps.tag.outputs.docker-tag }} ARCH="linux/amd64,linux/arm64,linux/386,linux/arm/v7,linux/arm/v6" + + - name: "[DEPLOY] Publish Docker manifest (only repo owner)" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make manifest-push TAG=${{ steps.tag.outputs.docker-tag }} # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id && ( diff --git a/.github/workflows/contributor.yml b/.github/workflows/contributor.yml new file mode 100644 index 0000000..721df3c --- /dev/null +++ b/.github/workflows/contributor.yml @@ -0,0 +1,90 @@ +--- + +# ------------------------------------------------------------------------------------------------- +# Job Name +# ------------------------------------------------------------------------------------------------- +name: build + + +# ------------------------------------------------------------------------------------------------- +# When to run +# ------------------------------------------------------------------------------------------------- +on: + # Runs on Pull Requests + pull_request: + + +jobs: + + # ----------------------------------------------------------------------------------------------- + # Job (1/2): BUILD + # ----------------------------------------------------------------------------------------------- + build: + name: "[ PHP-${{ matrix.version }} (${{ matrix.arch }}) ]" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + version: + - '5.3' + arch: + - 'linux/amd64' + - 'linux/arm64' + - 'linux/386' + - 'linux/arm/v7' + - 'linux/arm/v6' + # Only run for forks (contributor) + if: ${{ github.event.pull_request.head.repo.fork }} + steps: + + # ------------------------------------------------------------ + # Setup repository + # ------------------------------------------------------------ + - name: "[SETUP] Checkout repository" + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: "[SETUP] Setup QEMU environment" + uses: docker/setup-qemu-action@v1 + with: + image: tonistiigi/binfmt:latest + platforms: all + + - name: "[SETUP] Determine Docker tag" + id: tag + uses: cytopia/docker-tag@v0.3 + + # ------------------------------------------------------------ + # Build + # ------------------------------------------------------------ + - name: Build + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make build ARCH=${ARCH} + env: + ARCH: ${{ matrix.arch }} + + # ------------------------------------------------------------ + # Test + # ------------------------------------------------------------ + - name: "[TEST] Docker Image" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make test ARCH=${ARCH} + env: + ARCH: ${{ matrix.arch }} + + - name: "[TEST] Update README" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make update-readme ARCH=${ARCH} + env: + ARCH: ${{ matrix.arch }} + + - name: "[TEST] Verify README" + run: | + git diff --quiet || { echo "Build Changes"; git diff; git status; false; } diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 37ac143..9273cd5 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -15,171 +15,159 @@ on: - cron: '0 0 * * *' -# ------------------------------------------------------------------------------------------------- -# What to run -# ------------------------------------------------------------------------------------------------- jobs: - nightly: - name: "[ PHP-${{ matrix.version }} ] (ref: ${{ matrix.refs }})" + + # ----------------------------------------------------------------------------------------------- + # Job: BUILD + # ----------------------------------------------------------------------------------------------- + build: + name: "[ PHP-${{ matrix.version }} (${{ matrix.arch }}) ] (ref: ${{ matrix.refs }})" runs-on: ubuntu-latest strategy: - fail-fast: False + fail-fast: false matrix: version: - '5.3' + arch: + - 'linux/amd64' + - 'linux/arm64' + - 'linux/386' + - 'linux/arm/v7' + - 'linux/arm/v6' refs: - 'master' - - '0.21' + - '0.22' steps: # ------------------------------------------------------------ # Setup repository # ------------------------------------------------------------ - - name: Checkout repository + - name: "[SETUP] Checkout repository" uses: actions/checkout@v2 with: fetch-depth: 0 ref: ${{ matrix.refs }} - - name: Set variables - id: vars - run: | - - # Retrieve git info (tags, etc) - git fetch --all - - # Branch, Tag or Commit - GIT_TYPE="$( \ - curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \ - | sh \ - | grep '^GIT_TYPE' \ - | sed 's|.*=||g' \ - )" - # Branch name, Tag name or Commit Hash - GIT_SLUG="$( \ - curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \ - | sh \ - | grep '^GIT_NAME' \ - | sed 's|.*=||g' \ - )" - # Docker Tag - if [ "${GIT_TYPE}" = "BRANCH" ] && [ "${GIT_SLUG}" = "master" ]; then - DOCKER_TAG="latest" - else - DOCKER_TAG="${GIT_SLUG}" - fi - - # Output - echo "GIT_TYPE=${GIT_TYPE}" - echo "GIT_SLUG=${GIT_SLUG}" - echo "DOCKER_TAG=${DOCKER_TAG}" - - # Export variable - # https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files - echo "GIT_TYPE=${GIT_TYPE}" >> ${GITHUB_ENV} - echo "GIT_SLUG=${GIT_SLUG}" >> ${GITHUB_ENV} - echo "DOCKER_TAG=${DOCKER_TAG}" >> ${GITHUB_ENV} + - name: "[SETUP] Setup QEMU environment" + uses: docker/setup-qemu-action@v1 + with: + image: tonistiigi/binfmt:latest + platforms: all + - name: "[SETUP] Determine Docker tag" + id: tag + uses: cytopia/docker-tag@v0.3 # ------------------------------------------------------------ # Build # ------------------------------------------------------------ - name: Build - run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make build ARCH=${ARCH} env: - RETRIES: 20 - PAUSE: 10 + ARCH: ${{ matrix.arch }} # ------------------------------------------------------------ # Test # ------------------------------------------------------------ - - name: Test Docker Image - run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test + - name: "[TEST] Docker Image" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make test ARCH=${ARCH} + env: + ARCH: ${{ matrix.arch }} + + - name: "[TEST] Update README" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make update-readme ARCH=${ARCH} env: - RETRIES: 20 - PAUSE: 10 + ARCH: ${{ matrix.arch }} - - name: Test Repository Readme + - name: "[TEST] Verify README" run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make update-readme git diff --quiet || { echo "Build Changes"; git diff; git status; false; } + + # ------------------------------------------------------------ + # Deploy + # ------------------------------------------------------------ + - name: "[DEPLOY] Login" + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: "[DEPLOY] Publish architecture image (only repo owner)" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make push-arch TAG=${{ steps.tag.outputs.docker-tag }} ARCH=${ARCH} env: - RETRIES: 20 - PAUSE: 10 + ARCH: ${{ matrix.arch }} + # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions + if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id + && ( + (github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) + || + (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) + || + (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-')) + ) + + # ----------------------------------------------------------------------------------------------- + # Job (2/2): DEPLOY + # ----------------------------------------------------------------------------------------------- + deploy: + needs: [build] + name: "[ Deploy (ref: ${{ matrix.refs }})" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + version: + - '5.3' + refs: + - 'master' + - '0.22' + steps: + + # ------------------------------------------------------------ + # Setup repository + # ------------------------------------------------------------ + - name: "[SETUP] Checkout repository" + uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{ matrix.refs }} + - name: "[SETUP] Determine Docker tag" + id: tag + uses: cytopia/docker-tag@v0.3 # ------------------------------------------------------------ # Deploy # ------------------------------------------------------------ - - name: Publish images (only repo owner) - run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - - # Output - echo "GIT_TYPE=${GIT_TYPE}" - echo "GIT_SLUG=${GIT_SLUG}" - echo "DOCKER_TAG=${DOCKER_TAG}" - - # Tag image - retry make tag TAG=${DOCKER_TAG} - docker images - - # Login and Push - retry make login USER=${{ secrets.DOCKERHUB_USERNAME }} PASS=${{ secrets.DOCKERHUB_PASSWORD }} - retry make push TAG=${DOCKER_TAG} + - name: "[DEPLOY] Login" + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} - env: - RETRIES: 20 - PAUSE: 10 + - name: "[DEPLOY] Create Docker manifest" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make manifest-create TAG=${{ steps.tag.outputs.docker-tag }} ARCH="linux/amd64,linux/arm64,linux/386,linux/arm/v7,linux/arm/v6" + + - name: "[DEPLOY] Publish Docker manifest (only repo owner)" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make manifest-push TAG=${{ steps.tag.outputs.docker-tag }} # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id && ( diff --git a/Dockerfile b/Dockerfile index e7b8924..176913f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,27 @@ -FROM debian:jessie +FROM debian:stretch MAINTAINER "cytopia" # persistent / runtime deps -RUN set -xe \ +RUN set -eux \ && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \ ca-certificates \ curl \ libpcre3 \ librecode0 \ - libmysqlclient-dev \ + libmariadbclient-dev-compat \ libsqlite3-0 \ libxml2 \ && DEBIAN_FRONTEND=noninteractive apt-get purge -qq -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ && rm -rf /var/lib/apt/lists/* # phpize deps -RUN set -xe \ +RUN set -eux \ && DEBIAN_FRONTEND=noninteractive apt-get update -qq \ && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \ autoconf \ file \ + dpkg-dev \ g++ \ gcc \ libc-dev \ @@ -28,6 +29,11 @@ RUN set -xe \ pkg-config \ re2c \ xz-utils \ + && if [ "$(dpkg-architecture --query DEB_HOST_ARCH)" = "i386" ]; then \ + DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \ + g++-multilib \ + gcc-multilib; \ + fi \ && DEBIAN_FRONTEND=noninteractive apt-get purge -qq -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ && rm -rf /var/lib/apt/lists/* @@ -35,15 +41,20 @@ ENV PHP_INI_DIR /usr/local/etc/php RUN mkdir -p $PHP_INI_DIR/conf.d # compile openssl, otherwise --with-openssl won't work -RUN set -xe \ +RUN set -eux \ && OPENSSL_VERSION="1.0.1t" \ && cd /tmp \ && mkdir openssl \ - && curl -sL "https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz" -o openssl.tar.gz \ - && curl -sL "https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz.asc" -o openssl.tar.gz.asc \ + && update-ca-certificates \ + && curl -sS -k -L --fail "https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz" -o openssl.tar.gz \ + && curl -sS -k -L --fail "https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz.asc" -o openssl.tar.gz.asc \ && tar -xzf openssl.tar.gz -C openssl --strip-components=1 \ && cd /tmp/openssl \ - && ./config \ + && if [ "$(dpkg-architecture --query DEB_HOST_ARCH)" = "i386" ]; then \ + setarch i386 ./config -m32; \ + else \ + ./config; \ + fi \ && make depend \ && make -j"$(nproc)" \ && make install \ @@ -54,7 +65,7 @@ COPY data/docker-php-source /usr/local/bin/ # php 5.3 needs older autoconf # --enable-mysqlnd is included below because it's harder to compile after the fact the extensions are (since it's a plugin for several extensions, not an extension in itself) -RUN set -xe \ +RUN set -eux \ && buildDeps=" \ autoconf2.13 \ libcurl4-openssl-dev \ @@ -72,12 +83,24 @@ RUN set -xe \ && rm -rf /var/lib/apt/lists/* \ \ && mkdir -p /usr/src/php \ - && curl -SL "http://php.net/get/php-$PHP_VERSION.tar.xz/from/this/mirror" -o /usr/src/php.tar.xz \ - && curl -SL "http://php.net/get/php-$PHP_VERSION.tar.xz.asc/from/this/mirror" -o /usr/src/php.tar.xz.asc \ - && cd /usr/src \ + && curl -sS -k -L --fail "http://php.net/get/php-$PHP_VERSION.tar.xz/from/this/mirror" -o /usr/src/php.tar.xz \ + && curl -sS -k -L --fail "http://php.net/get/php-$PHP_VERSION.tar.xz.asc/from/this/mirror" -o /usr/src/php.tar.xz.asc \ && docker-php-source extract \ - && cd /usr/src/php \ + && cd /usr/src/php \ + \ + && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ + && debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)" \ + \ + # Fix libmariadbclient lib location + && find /usr/lib/ -name '*mariadbclient*' | xargs -n1 sh -c 'ln -s "${1}" "/usr/lib/$( basename "${1}" | sed "s|libmariadbclient|libmysqlclient|g" )"' -- \ + \ + # https://bugs.php.net/bug.php?id=74125 + && if [ ! -d /usr/include/curl ]; then \ + ln -sT "/usr/include/$debMultiarch/curl" /usr/local/include/curl; \ + fi \ + \ && ./configure \ + --host="${gnuArch}" \ --with-config-file-path="$PHP_INI_DIR" \ --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ --enable-fpm \ diff --git a/Makefile b/Makefile index 29443d4..3292d4c 100644 --- a/Makefile +++ b/Makefile @@ -7,24 +7,30 @@ endif # Docker configuration # ------------------------------------------------------------------------------------------------- -.PHONY: build rebuild test tag pull login push enter - DIR = . FILE = Dockerfile IMAGE = devilbox/php-fpm-5.3 TAG = latest +ARCH = linux/amd64 +NO_CACHE = # ------------------------------------------------------------------------------------------------- # Default Target # ------------------------------------------------------------------------------------------------- - +.PHONY: help help: @echo "lint Lint project files and repository" + @echo @echo "build Build Docker image" @echo "rebuild Build Docker image without cache" + @echo + @echo "manifest-create Create multi-arch manifest" + @echo "manifest-push Push multi-arch manifest" + @echo @echo "test Test built Docker image" @echo "update-readme Update README.md with PHP modules" + @echo @echo "tag [TAG=...] Retag Docker image" @echo "login USER=... PASS=... Login to Docker hub" @echo "push [TAG=...] Push Docker image to Docker hub" @@ -33,44 +39,72 @@ help: # ------------------------------------------------------------------------------------------------- # Lint Targets # ------------------------------------------------------------------------------------------------- -# +.PHONY: lint lint: lint-workflow +.PHONY: lint-workflow lint-workflow: @\ GIT_CURR_MAJOR="$$( git tag | sort -V | tail -1 | sed 's|\.[0-9]*$$||g' )"; \ GIT_CURR_MINOR="$$( git tag | sort -V | tail -1 | sed 's|^[0-9]*\.||g' )"; \ GIT_NEXT_TAG="$${GIT_CURR_MAJOR}.$$(( GIT_CURR_MINOR + 1 ))"; \ - if ! grep 'refs:' -A 100 .github/workflows/nightly.yml \ - | grep " - '$${GIT_NEXT_TAG}'" >/dev/null; then \ + grep 'refs:' -A 20 .github/workflows/nightly.yml \ + | grep '^ -' \ + | grep -v master \ + | while read -r i; do \ + if ! echo "$${i}" | grep -- "- '$${GIT_NEXT_TAG}'" >/dev/null; then \ echo "[ERR] New Tag required in .github/workflows/nightly.yml: $${GIT_NEXT_TAG}"; \ exit 1; \ else \ echo "[OK] Git Tag present in .github/workflows/nightly.yml: $${GIT_NEXT_TAG}"; \ - fi + fi \ + done # ------------------------------------------------------------------------------------------------- # Build Targets # ------------------------------------------------------------------------------------------------- - +.PHONY: build build: - docker build -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR) + docker build --platform $(ARCH) $(NO_CACHE) -t $(IMAGE):$(TAG) -f $(DIR)/$(FILE) $(DIR) +.PHONY: rebuild +rebuild: NO_CACHE=--no-cache rebuild: pull-base-image - docker build --no-cache -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR) +rebuild: build # ------------------------------------------------------------------------------------------------- -# Test Targets +# Manifest Targets # ------------------------------------------------------------------------------------------------- +.PHONY: manifest-create +manifest-create: + @echo "docker manifest create \ + $(IMAGE):$(TAG) \ + $$( echo $(ARCH) | sed 's/,/ /g' | sed 's|/|-|g' | xargs -n1 sh -c 'printf -- " --amend $(IMAGE):$(TAG)-manifest-$${1}"' -- )" \ + | sed 's/\s\s*/ /g' \ + | sed 's/--/\\\n --/g' + @echo "docker manifest create \ + $(IMAGE):$(TAG) \ + $$( echo $(ARCH) | sed 's/,/ /g' | sed 's|/|-|g' | xargs -n1 sh -c 'printf -- " --amend $(IMAGE):$(TAG)-manifest-$${1}"' -- )" \ + | bash + +.PHONY: manifest-push +manifest-push: + docker manifest push $(IMAGE):$(TAG) + +# ------------------------------------------------------------------------------------------------- +# Test Targets +# ------------------------------------------------------------------------------------------------- +.PHONY: test test: - ./tests/test.sh $(IMAGE) + ./tests/test.sh $(IMAGE) $(ARCH) +.PHONY: update-readme update-readme: cat "./README.md" \ - | perl -00 -pe "s/.*/\n$$(./tests/get-modules.sh)\n/s" \ + | perl -0 -pe "s/.*/\n$$(./tests/get-modules.sh $(IMAGE) $(ARCH))\n/s" \ > "./README.md.tmp" yes | mv -f "./README.md.tmp" "./README.md" @@ -78,24 +112,32 @@ update-readme: # ------------------------------------------------------------------------------------------------- # Deploy Targets # ------------------------------------------------------------------------------------------------- - +.PHONY: tag tag: docker tag $(IMAGE) $(IMAGE):$(TAG) +.PHONY: login login: yes | docker login --username $(USER) --password $(PASS) +.PHONY: push push: @$(MAKE) tag TAG=$(TAG) docker push $(IMAGE):$(TAG) +.PHONY: push-arch +push-arch: + $(MAKE) tag TAG=$(TAG)-manifest-$(subst /,-,$(ARCH)) + docker push $(IMAGE):$(TAG)-manifest-$(subst /,-,$(ARCH)) + # ------------------------------------------------------------------------------------------------- # Helper Targets # ------------------------------------------------------------------------------------------------- - +.PHONY: enter enter: - docker run --rm --name $(subst /,-,$(IMAGE)) -it --entrypoint=bash $(ARG) $(IMAGE) + docker run --rm --platform=$(ARCH) -it --entrypoint=bash $(ARG) $(IMAGE) +.PHONY: pull-base-image pull-base-image: - @docker pull $(shell grep FROM Dockerfile | sed 's/^FROM\s*//g';) + @docker pull --platform $(ARCH) $(shell grep FROM Dockerfile | sed 's/^FROM\s*//g';) diff --git a/README.md b/README.md index 93cb00d..5ba20d7 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ [![](https://images.microbadger.com/badges/image/devilbox/php-fpm-5.3.svg)](https://microbadger.com/images/devilbox/php-fpm-5.3 "php-fpm-5.3") [![License](https://img.shields.io/badge/license-MIT-%233DA639.svg)](https://opensource.org/licenses/MIT) +**Available Architectures:** `amd64`, `arm64`, `386`, `arm/v7`, `arm/v6` + This repository will provide you a fully functional PHP-FPM 5.3 Docker image built from [official sources](http://php.net) nightly. PHP 5.3 [reached EOL](http://php.net/eol.php) on 14 Aug 2014 and thus, official docker support was [dropped](https://github.com/docker-library/php/pull/20). It provides the base for [Devilbox PHP-FPM Docker images](https://github.com/devilbox/docker-php-fpm). | Docker Hub | Upstream Project | @@ -26,6 +28,7 @@ Have a look at the following similar Devilbox base images for which no official * [PHP-FPM 7.4](https://github.com/devilbox/docker-php-fpm-7.4) * [PHP-FPM 8.0](https://github.com/devilbox/docker-php-fpm-8.0) * [PHP-FPM 8.1](https://github.com/devilbox/docker-php-fpm-8.1) +* [PHP-FPM 8.2](https://github.com/devilbox/docker-php-fpm-8.2) In case you are looking for development and production ready PHP-FPM images for all versions, which have a vast amount of modules enabled by default go here: diff --git a/tests/get-modules.sh b/tests/get-modules.sh index f7c423d..77192f2 100755 --- a/tests/get-modules.sh +++ b/tests/get-modules.sh @@ -4,14 +4,17 @@ set -e set -u set -o pipefail -MODULES="$( docker run --rm -t --entrypoint=php devilbox/php-fpm-5.3 -m \ +IMAGE="${1:-devilbox/php-fpm-5.3}" +ARCH="${2:-linux/amd64}" + +MODULES="$( docker run --rm -t --platform "${ARCH}" --entrypoint=php "${IMAGE}" -m \ | grep -vE '(^\[)|(^\s*$)' \ | sort -u -f )" echo "| Module | Built-in |" echo "|--------------|-----------|" -echo "${MODULES}" | while read line; do +echo "${MODULES}" | while read -r line; do line="$( echo "${line}" | sed 's/\r//g' | xargs )" printf "| %-12s | ✔ |\n" "${line}" done diff --git a/tests/test.sh b/tests/test.sh index a9b9c9d..2775ee7 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash - -set -e -set -u +set -eu set -o pipefail IMAGE="${1}" +ARCH="${2}" -docker run --rm --entrypoint=php "${IMAGE}" -v | grep -E '^PHP 5\.3' -docker run --rm --entrypoint=php-fpm "${IMAGE}" -v | grep -E '^PHP 5\.3' +docker run --rm --platform "${ARCH}" --entrypoint=php "${IMAGE}" -v | grep -E '^PHP 5\.3' +docker run --rm --platform "${ARCH}" --entrypoint=php-fpm "${IMAGE}" -v | grep -E '^PHP 5\.3'