diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f36067..05c01da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,8 +10,6 @@ name: build # When to run # ------------------------------------------------------------------------------------------------- on: - # Runs on Pull Requests - pull_request: # Runs on Push push: @@ -19,7 +17,7 @@ on: jobs: # ----------------------------------------------------------------------------------------------- - # Job: BUILD + # Job (1/2): BUILD # ----------------------------------------------------------------------------------------------- build: name: "[ PHP-${{ matrix.version }} (${{ matrix.arch }}) ]" @@ -32,168 +30,79 @@ jobs: 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 up QEMU + - name: "[SETUP] Setup QEMU environment" uses: docker/setup-qemu-action@v1 with: image: tonistiigi/binfmt:latest - platforms: arm64 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - 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} + 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 ARCH=${ARCH} + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make build ARCH=${ARCH} env: ARCH: ${{ matrix.arch }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ # 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 ARCH=${ARCH} + - name: "[TEST] Docker Image" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make test ARCH=${ARCH} env: ARCH: ${{ matrix.arch }} - RETRIES: 20 - PAUSE: 10 - - name: Test Repository 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 ARCH=${ARCH} - git diff --quiet || { echo "Build Changes"; git diff; git status; false; } + - name: "[TEST] Update README" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make update-readme ARCH=${ARCH} env: ARCH: ${{ matrix.arch }} - RETRIES: 20 - PAUSE: 10 + - name: "[TEST] Verify README" + run: | + git diff --quiet || { echo "Build Changes"; git diff; git status; false; } # ------------------------------------------------------------ # Deploy # ------------------------------------------------------------ - - name: Publish architecture 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 + - name: "[DEPLOY] Login" + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} - # Login and Push - retry make login USER=${{ secrets.DOCKERHUB_USERNAME }} PASS=${{ secrets.DOCKERHUB_PASSWORD }} - retry make push TAG=${DOCKER_TAG}-manifest-${ARCH##*/} + - 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: ARCH: ${{ matrix.arch }} - RETRIES: 20 - PAUSE: 10 # 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 && ( @@ -205,7 +114,7 @@ jobs: ) # ----------------------------------------------------------------------------------------------- - # Job: DEPLOY + # Job (2/2): DEPLOY # ----------------------------------------------------------------------------------------------- deploy: needs: [build] @@ -221,88 +130,35 @@ jobs: # ------------------------------------------------------------ # 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] Determine Docker tag" + id: tag + uses: cytopia/docker-tag@v0.3 # ------------------------------------------------------------ # Deploy # ------------------------------------------------------------ - - name: Publish final multi-arch image (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}" - - # Login - retry make login USER=${{ secrets.DOCKERHUB_USERNAME }} PASS=${{ secrets.DOCKERHUB_PASSWORD }} + - name: "[DEPLOY] Login" + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} - # Create manifest - docker manifest create \ - devilbox/php-fpm-8.2:${DOCKER_TAG} \ - --amend devilbox/php-fpm-8.2:${DOCKER_TAG}-manifest-amd64 \ - --amend devilbox/php-fpm-8.2:${DOCKER_TAG}-manifest-arm64 + - 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" - # Push manifest - docker manifest push devilbox/php-fpm-8.2:${DOCKER_TAG} - env: - RETRIES: 20 - PAUSE: 10 + - 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..2570bfa --- /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: + - '8.2' + 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 a6fa1e0..eead512 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -31,172 +31,83 @@ jobs: arch: - 'linux/amd64' - 'linux/arm64' + - 'linux/386' + - 'linux/arm/v7' + - 'linux/arm/v6' refs: - 'master' - - '0.2' + - '0.3' steps: # ------------------------------------------------------------ # Setup repository # ------------------------------------------------------------ - - name: Checkout repository + - name: "[SETUP] Checkout repository" uses: actions/checkout@v2 with: fetch-depth: 0 ref: ${{ matrix.refs }} - - name: Set up QEMU + - name: "[SETUP] Setup QEMU environment" uses: docker/setup-qemu-action@v1 with: image: tonistiigi/binfmt:latest - platforms: arm64 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - 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} + 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 ARCH=${ARCH} + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make build ARCH=${ARCH} env: ARCH: ${{ matrix.arch }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ # 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 ARCH=${ARCH} + - name: "[TEST] Docker Image" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make test ARCH=${ARCH} env: ARCH: ${{ matrix.arch }} - RETRIES: 20 - PAUSE: 10 - - name: Test Repository 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 ARCH=${ARCH} - git diff --quiet || { echo "Build Changes"; git diff; git status; false; } + - name: "[TEST] Update README" + uses: cytopia/shell-command-retry-action@v0.1 + with: + command: | + make update-readme ARCH=${ARCH} env: ARCH: ${{ matrix.arch }} - RETRIES: 20 - PAUSE: 10 + - name: "[TEST] Verify README" + run: | + git diff --quiet || { echo "Build Changes"; git diff; git status; false; } # ------------------------------------------------------------ # Deploy # ------------------------------------------------------------ - - name: Publish architecture 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 + - name: "[DEPLOY] Login" + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} - # Login and Push - retry make login USER=${{ secrets.DOCKERHUB_USERNAME }} PASS=${{ secrets.DOCKERHUB_PASSWORD }} - retry make push TAG=${DOCKER_TAG}-manifest-${ARCH##*/} + - 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: ARCH: ${{ matrix.arch }} - RETRIES: 20 - PAUSE: 10 # 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 && ( @@ -208,7 +119,7 @@ jobs: ) # ----------------------------------------------------------------------------------------------- - # Job: DEPLOY + # Job (2/2): DEPLOY # ----------------------------------------------------------------------------------------------- deploy: needs: [build] @@ -221,95 +132,42 @@ jobs: - '8.2' refs: - 'master' - - '0.2' + - '0.3' 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] Determine Docker tag" + id: tag + uses: cytopia/docker-tag@v0.3 # ------------------------------------------------------------ # Deploy # ------------------------------------------------------------ - - name: Publish final multi-arch image (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}" - - # Login - retry make login USER=${{ secrets.DOCKERHUB_USERNAME }} PASS=${{ secrets.DOCKERHUB_PASSWORD }} + - name: "[DEPLOY] Login" + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} - # Create manifest - docker manifest create \ - devilbox/php-fpm-8.2:${DOCKER_TAG} \ - --amend devilbox/php-fpm-8.2:${DOCKER_TAG}-manifest-amd64 \ - --amend devilbox/php-fpm-8.2:${DOCKER_TAG}-manifest-arm64 + - 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" - # Push manifest - docker manifest push devilbox/php-fpm-8.2:${DOCKER_TAG} - env: - RETRIES: 20 - PAUSE: 10 + - 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/Makefile b/Makefile index 5e3706a..4a413b2 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,6 @@ endif # Docker configuration # ------------------------------------------------------------------------------------------------- -.PHONY: build rebuild test tag pull login push enter - DIR = . FILE = Dockerfile IMAGE = devilbox/php-fpm-8.2 @@ -20,13 +18,19 @@ 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" @@ -35,15 +39,16 @@ 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 ))"; \ - grep 'refs:' -A 100 .github/workflows/nightly.yml \ + grep 'refs:' -A 20 .github/workflows/nightly.yml \ | grep '^ -' \ | grep -v master \ | while read -r i; do \ @@ -59,22 +64,44 @@ lint-workflow: # ------------------------------------------------------------------------------------------------- # Build Targets # ------------------------------------------------------------------------------------------------- - +.PHONY: build build: - docker buildx build --output type=docker --platform=$(ARCH) $(NO_CACHE) -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR) + docker build --platform=$(ARCH) $(NO_CACHE) -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR) +.PHONY: rebuild rebuild: NO_CACHE=--no-cache rebuild: pull-base-image 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) $(ARCH) +.PHONY: update-readme update-readme: cat "./README.md" \ | perl -0 -pe "s/.*/\n$$(./tests/get-modules.sh $(IMAGE) $(ARCH))\n/s" \ @@ -85,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';) diff --git a/README.md b/README.md index ead74d9..3e99af0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![](https://images.microbadger.com/badges/image/devilbox/php-fpm-8.2.svg)](https://microbadger.com/images/devilbox/php-fpm-8.2 "php-fpm-8.2") [![License](https://img.shields.io/badge/license-MIT-%233DA639.svg)](https://opensource.org/licenses/MIT) -**Supported Architectures:** AMD64, ARM64 +**Available Architectures:** `amd64`, `arm64`, `386`, `arm/v7`, `arm/v6` This repository will provide you a fully functional PHP-FPM 8.2 Docker image built from [official sources](https://github.com/php/php-src) nightly. It provides the base for [Devilbox PHP-FPM Docker images](https://github.com/devilbox/docker-php-fpm). diff --git a/tests/test.sh b/tests/test.sh index 0711ba5..778213e 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -7,5 +7,10 @@ set -o pipefail IMAGE="${1:-devilbox/php-fpm-8.2}" ARCH="${2:-linux/amd64}" +echo +echo "\$ docker run --rm --platform ${ARCH} --entrypoint=php ${IMAGE} -v | grep -E '^PHP 8\.2'" docker run --rm --platform "${ARCH}" --entrypoint=php "${IMAGE}" -v | grep -E '^PHP 8\.2' + +echo +echo "\$ docker run --rm --platform ${ARCH} --entrypoint=php-fpm ${IMAGE} -v | grep -E '^PHP 8\.2'" docker run --rm --platform "${ARCH}" --entrypoint=php-fpm "${IMAGE}" -v | grep -E '^PHP 8\.2'