diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..f2c3051a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,29 @@ +# +# JBZoo Toolbox - CI-Report-Converter. +# +# This file is part of the JBZoo Toolbox project. +# For the full copyright and license information, please view the LICENSE +# file that was distributed with this source code. +# +# @license MIT +# @copyright Copyright (C) JBZoo.com, All rights reserved. +# @see https://github.com/JBZoo/CI-Report-Converter +# + +.git +.idea +.github +build +tests +vendor +schema-examples +.DS_Store +.editorconfig +.gitattributes +.gitignore +.phan.php +.phpunit.result.cache +action.yml +box.json.dist +phpunit.xml.dist +Makefile diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bc869c47..8d9f2d21 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -174,3 +174,21 @@ jobs: with: name: Reports - ${{ matrix.php-version }} path: build/ + + docker: + name: Docker + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: 🐳 Building Docker Image + run: make build-docker + + - name: Trying to use the Docker Image + run: docker run --rm jbzoo/csv-blueprint --ansi + + - name: Reporting example via Docker + run: make demo-invalid-docker diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml new file mode 100644 index 00000000..7bd1c8eb --- /dev/null +++ b/.github/workflows/release-docker.yml @@ -0,0 +1,33 @@ +# +# JBZoo Toolbox - Csv-Blueprint. +# +# This file is part of the JBZoo Toolbox project. +# For the full copyright and license information, please view the LICENSE +# file that was distributed with this source code. +# +# @license MIT +# @copyright Copyright (C) JBZoo.com, All rights reserved. +# @see https://github.com/JBZoo/Csv-Blueprint +# + +name: Publish Docker Image + +on: + release: + types: [ published ] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v3 + with: + push: true + tags: jbzoo/csv-blueprint:${{ env.GITHUB_REF_NAME }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..eba500d5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# +# JBZoo Toolbox - Csv-Blueprint. +# +# This file is part of the JBZoo Toolbox project. +# For the full copyright and license information, please view the LICENSE +# file that was distributed with this source code. +# +# @license MIT +# @copyright Copyright (C) JBZoo.com, All rights reserved. +# @see https://github.com/JBZoo/Csv-Blueprint +# + +FROM php:8.1-cli-alpine +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + +# Install PHP extensions +ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ +RUN install-php-extensions opcache gd @composer + +# Install application +ENV COMPOSER_ALLOW_SUPERUSER=1 +COPY . /app +RUN cd /app \ + && composer install --no-dev --optimize-autoloader --no-progress \ + && composer clear-cache +RUN chmod +x app/csv-blueprint + +# Color output by default +ENV TERM_PROGRAM=Hyper + +ENTRYPOINT ["/app/csv-blueprint"] diff --git a/Makefile b/Makefile index 2f8cfa4d..972397cd 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ build: ##@Project Install all 3rd party dependencies $(call title,"Install/Update all 3rd party dependencies") @composer install @make build-phar - @make create-symlink + @rm -f `pwd`/ci-report-converter update: ##@Project Install/Update all 3rd party dependencies @@ -31,21 +31,31 @@ update: ##@Project Install/Update all 3rd party dependencies @make build-phar -create-symlink: ##@Project Create Symlink (alias for testing) - @ln -sfv `pwd`/csv-blueprint `pwd`/vendor/bin/csv-blueprint - - test-all: ##@Project Run all project tests at once @make test @make codestyle +build-docker: + $(call title,"Building Docker Image") + @docker build -t jbzoo/csv-blueprint . + + demo-valid: ##@Project Run demo valid CSV $(call title,"Demo - Valid CSV") @${PHP_BIN} ./csv-blueprint validate:csv \ --csv=./tests/fixtures/demo.csv \ --schema=./tests/schemas/demo_valid.yml +demo-invalid-docker: ##@Project Run demo valid CSV (via Docker) + $(call title,"Demo - Valid CSV \(via Docker\)") + @docker run --rm \ + -v `pwd`:/parent-host \ + jbzoo/csv-blueprint \ + validate:csv \ + --csv=/parent-host/tests/fixtures/demo.csv \ + --schema=/parent-host/tests/schemas/demo_invalid.yml + demo-invalid: ##@Project Run demo invalid CSV $(call title,"Demo - Invalid CSV") diff --git a/composer.json b/composer.json index f1085b3d..2cc18867 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,8 @@ "config" : { "optimize-autoloader" : true, - "allow-plugins" : {"composer/package-versions-deprecated" : true} + "allow-plugins" : {"composer/package-versions-deprecated" : true}, + "platform-check" : true }, "extra" : { diff --git a/composer.lock b/composer.lock index 9ff9a5bd..5f62fb9b 100644 --- a/composer.lock +++ b/composer.lock @@ -5071,12 +5071,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "83b3589bb774f27084c7f358c13f465d94afa036" + "reference": "bb15a6dc9a8493ace041a6de2929eb63ba0809ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/83b3589bb774f27084c7f358c13f465d94afa036", - "reference": "83b3589bb774f27084c7f358c13f465d94afa036", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/bb15a6dc9a8493ace041a6de2929eb63ba0809ef", + "reference": "bb15a6dc9a8493ace041a6de2929eb63ba0809ef", "shasum": "" }, "conflict": { @@ -5803,7 +5803,7 @@ "type": "tidelift" } ], - "time": "2024-03-08T12:05:25+00:00" + "time": "2024-03-10T05:04:21+00:00" }, { "name": "sabre/event", @@ -8027,16 +8027,16 @@ }, { "name": "vimeo/psalm", - "version": "5.22.2", + "version": "5.23.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "d768d914152dbbf3486c36398802f74e80cfde48" + "reference": "005e3184fb6de4350a873b9b8c4dc3cede9db762" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/d768d914152dbbf3486c36398802f74e80cfde48", - "reference": "d768d914152dbbf3486c36398802f74e80cfde48", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/005e3184fb6de4350a873b9b8c4dc3cede9db762", + "reference": "005e3184fb6de4350a873b9b8c4dc3cede9db762", "shasum": "" }, "require": { @@ -8133,7 +8133,7 @@ "issues": "https://github.com/vimeo/psalm/issues", "source": "https://github.com/vimeo/psalm" }, - "time": "2024-02-22T23:39:07+00:00" + "time": "2024-03-09T19:39:11+00:00" }, { "name": "webmozart/assert", diff --git a/csv-blueprint b/csv-blueprint old mode 100644 new mode 100755