Skip to content

Commit

Permalink
Adjust for fink
Browse files Browse the repository at this point in the history
  • Loading branch information
M-arcus committed Mar 15, 2024
1 parent ede75a8 commit dd70871
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 30 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ jobs:

- name: Build base and push
run: ./build-base.sh
phpmd:
fink:
needs: [base]
runs-on: ubuntu-latest
steps:
- name: Get latest PHP Mess Detector version
id: phpmd_version
id: fink_version
run: |
VERSION=$(curl https://api.github.com/repos/phpmd/phpmd/releases/latest | jq '.tag_name | ltrimstr("v")' -r)
echo "PHPMD_VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
echo "PHPMD_VERSION=${VERSION}" >> "$GITHUB_ENV"
VERSION=$(curl https://api.github.com/repos/dantleech/fink/releases/latest | jq '.tag_name | ltrimstr("v")' -r)
echo "FINK_VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
echo "FINK_VERSION=${VERSION}" >> "$GITHUB_ENV"
- name: Login into Github Docker Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
Expand All @@ -56,9 +56,9 @@ jobs:
push: true
platforms: linux/amd64,linux/arm64
build-args: |
PHP_PHPMD_VERSION=${{ steps.phpmd_version.outputs.PHPMD_VERSION }}
PHP_FINK_VERSION=${{ steps.fink_version.outputs.FINK_VERSION }}
tags: |
marcusmu/php-mess-detector:latest
marcusmu/php-mess-detector:${{ steps.phpmd_version.outputs.PHPMD_VERSION }}
ghcr.io/m-arcus/php-mess-detector:latest
ghcr.io/m-arcus/php-mess-detector:${{ steps.phpmd_version.outputs.PHPMD_VERSION }}
marcusmu/php-fink:latest
marcusmu/php-fink:${{ steps.fink_version.outputs.FINK_VERSION }}
ghcr.io/m-arcus/php-fink:latest
ghcr.io/m-arcus/php-fink:${{ steps.fink_version.outputs.FINK_VERSION }}
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM ghcr.io/m-arcus/php-mess-detector:base
FROM ghcr.io/m-arcus/php-fink:base

ARG PHP_PHPMD_VERSION=2.15.0
ARG PHP_PHPMD_VERSION=0.10.3

LABEL org.opencontainers.image.authors="M-arcus" \
org.opencontainers.image.url="https://github.com/phpmd/phpmd/" \
org.opencontainers.image.documentation="https://phpmd.org/documentation/index.html" \
org.opencontainers.image.source="https://github.com/M-arcus/php-mess-detector-docker" \
org.opencontainers.image.url="https://github.com/dantleech/fink/" \
org.opencontainers.image.documentation="https://github.com/dantleech/fink/blob/master/README.md" \
org.opencontainers.image.source="https://github.com/M-arcus/php-fink-docker" \
org.opencontainers.image.vendor="M-arcus" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.title="PHP Mess Detector"
org.opencontainers.image.title="Fink"

ADD https://github.com/phpmd/phpmd/releases/download/${PHP_PHPMD_VERSION}/phpmd.phar /phpmd.phar
ADD https://github.com/dantleech/fink/releases/download/${PHP_PHPMD_VERSION}/fink.phar /fink.phar

ENTRYPOINT ["/usr/bin/php", "/phpmd.phar"]
ENTRYPOINT ["/usr/bin/php", "/fink.phar"]
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Small PHP-Mess-Detector Docker image
# Small Fink Docker image

This image uses Wolfi-OS to create a very small PHPMD Docker image and still glibc, to be used in CI/CD pipelines.
This image uses Wolfi-OS to create a very small [Fink](https://github.com/dantleech/fink) Docker image and still glibc, to be used in CI/CD pipelines.

## Usage

```bash
# or alternative use ghcr.io/m-arcus/php-mess-detector:latest
docker run --rm -v $(pwd):$(pwd) -w $(pwd) marcusmu/php-mess-detector:latest /path/to/source text codesize
# or alternative use ghcr.io/m-arcus/php-fink:latest
docker run --rm -v $(pwd):$(pwd) -w $(pwd) marcusmu/php-fink:latest https://my.website.com/ --output=result.json --exclude-url=Account --insecure
```

If you don't want to pass the as arguments, you can create your regular `phpmd.xml` (and `phpmd.baseline.xml` and `.phpmd.result-cache.php` (`--cache`)) file and PHP Mess Detector will pick it up as usual.
If you want to scan for broken links in a website, you can use the following command:

```bash
cat result.json | jq -c '. | select(.status!=200) | {status: .status, url: .url, referrer: .referrer}' | jq
```
10 changes: 5 additions & 5 deletions build-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ docker run \
-w /work \
cgr.dev/chainguard/apko \
build \
wolfi-base.yaml ghcr.io/m-arcus/php-mess-detector:base base.tar
wolfi-base.yaml ghcr.io/m-arcus/php-fink:base base.tar

docker load < base.tar

rm -f base.tar sbom*

docker push ghcr.io/m-arcus/php-mess-detector:base-amd64
docker push ghcr.io/m-arcus/php-mess-detector:base-arm64
docker push ghcr.io/m-arcus/php-fink:base-amd64
docker push ghcr.io/m-arcus/php-fink:base-arm64

docker manifest create ghcr.io/m-arcus/php-mess-detector:base --amend ghcr.io/m-arcus/php-mess-detector:base-amd64 --amend ghcr.io/m-arcus/php-mess-detector:base-arm64
docker manifest create ghcr.io/m-arcus/php-fink:base --amend ghcr.io/m-arcus/php-fink:base-amd64 --amend ghcr.io/m-arcus/php-fink:base-arm64

docker manifest push ghcr.io/m-arcus/php-mess-detector:base
docker manifest push ghcr.io/m-arcus/php-fink:base
2 changes: 0 additions & 2 deletions wolfi-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ contents:
packages:
- wolfi-base
- php-8.2
- php-8.2-dom
- php-8.2-mbstring
- php-8.2-phar
- php-8.2-simplexml
- php-8.2-xml
Expand Down

0 comments on commit dd70871

Please sign in to comment.