From c70a77ace7417d7e3bb4c0b2b005bcb31bf20757 Mon Sep 17 00:00:00 2001 From: Hannes Giesenow Date: Thu, 14 Dec 2023 13:01:21 +0100 Subject: [PATCH] Initial setup --- .github/workflows/docker-image.yml | 44 ++++++++++++++++++++++++++++++ .gitignore | 4 +++ composer.json | 40 +++++++++++++++++++++++++++ doc/development.md | 16 +++++++++++ docker-compose.yml | 6 ++++ docker/Dockerfile | 35 ++++++++++++++++++++++++ 6 files changed, 145 insertions(+) create mode 100644 .github/workflows/docker-image.yml create mode 100644 .gitignore create mode 100644 composer.json create mode 100644 doc/development.md create mode 100644 docker-compose.yml create mode 100644 docker/Dockerfile diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..74aa7d6 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,44 @@ +name: Create and publish a Docker image + +on: + schedule: + - cron: '0 9 1 * *' + push: + branches: + - 'main' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}/php + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: docker + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a040318 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/.idea +vendor/ +composer.lock +docker-compose.override.yml diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..74e8767 --- /dev/null +++ b/composer.json @@ -0,0 +1,40 @@ +{ + "name": "elbformat/ibexa-icon-fieldtype", + "description": "Field type to select an icon from a predefined set.", + "type": "symfony-bundle", + "license": "MIT", + "keywords": [ + "ibexa", + "icon", + "field-type" + ], + "authors": [ + { + "name": "Hannes Giesenow", + "email": "hannes.giesenow@format-h.com", + "role": "Lead Developer" + } + ], + "autoload": { + "psr-4": { + "Elbformat\\IbexaIconFieldtype\\": "src/" + } + }, + "require": { + "php": ">=8.1", + "ezsystems/ezplatform-core": "^2.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "symfony/runtime": true, + "composer/package-versions-deprecated": true, + "php-http/discovery": false, + "symfony/flex": true, + "ibexa/post-install": true + } + } +} diff --git a/doc/development.md b/doc/development.md new file mode 100644 index 0000000..f0b2230 --- /dev/null +++ b/doc/development.md @@ -0,0 +1,16 @@ +For local development you can use docker-compose. +```bash +docker-compose run php sh +composer install +``` + +Enable xdebug inside the container +```bash +export XDEBUG_CONFIG="client_host=172.17.0.1 idekey=PHPSTORM" +export XDEBUG_MODE="debug" +``` + +Run tests +```bash +vendor/bin/phpunit +``` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7ba0d98 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,6 @@ +version: '2.1' +services: + php: + image: ghcr.io/elbformat/ibexa-icon-fieldtype/php + volumes: + - ./:/var/www diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..2d7f176 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,35 @@ +FROM php:8.2-fpm-alpine + +COPY --from=composer:2.5 /usr/bin/composer /usr/local/bin/composer + +# ext-intl +RUN apk add --no-cache icu icu-data-full && \ + apk add --no-cache --virtual .build-deps icu-dev && \ + docker-php-ext-install intl && \ + apk del .build-deps && \ + rm -rf /tmp/* + +#ext-xsl +RUN apk add --no-cache libxslt && \ + apk add --no-cache --virtual .build-deps libxslt-dev && \ + docker-php-ext-install xsl && \ + apk del .build-deps && \ + rm -rf /tmp/* + +# xdebug +RUN apk add --no-cache --virtual .build-deps autoconf g++ make linux-headers && \ + pecl install xdebug-3.2.1 && \ + docker-php-ext-enable xdebug && \ + apk del .build-deps && \ + rm -rf /tmp/* + +# ext-gd +RUN apk add --no-cache libpng libjpeg-turbo freetype && \ + apk add --no-cache --virtual .build-deps libpng-dev libjpeg-turbo-dev freetype-dev && \ + docker-php-ext-configure gd && \ + docker-php-ext-install gd && \ + apk del .build-deps && \ + rm -rf /tmp/* + +RUN rmdir /var/www/html +WORKDIR /var/www \ No newline at end of file