diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5b45918 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,16 @@ +name: GitHub Actions + +on: push + +env: + REPO: lazerg/laravel + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run build script + run: chmod +x ./build.sh && ./build.sh \ No newline at end of file diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml deleted file mode 100644 index e9f6d5b..0000000 --- a/.github/workflows/php.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: GitHub Actions - -on: push - -env: - REPO: lazerg/laravel - DOCKER_USER: ${{secrets.DOCKER_USER}} - DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} - -jobs: - php80: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: docker login - - run: | - docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - - - name: Build the Docker image - run: docker build . --file php80.Dockerfile --tag $REPO:php80 - - - name: Docker push as php80 - run: docker push $REPO:php80 - - php81: - needs: php80 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: docker login - - run: | - docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - - - name: Build the Docker image - run: docker build . --file php81.Dockerfile --tag $REPO:php81 - - - name: Docker push as php81 - run: docker push $REPO:php81 - - php82: - needs: php81 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: docker login - - run: | - docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - - - name: Build the Docker image - run: docker build . --file php82.Dockerfile --tag $REPO:php82 - - - name: Docker push as php82 - run: docker push $REPO:php82 - - php83: - needs: php82 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: docker login - - run: | - docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - - - name: Build the Docker image - run: docker build . --file php83.Dockerfile --tag $REPO:latest --tag $REPO:php83 - - - name: Docker push as latest - run: docker push $REPO:latest - - - name: Docker push as php83 - run: docker push $REPO:php83 diff --git a/README.MD b/README.MD deleted file mode 100644 index 4e72215..0000000 --- a/README.MD +++ /dev/null @@ -1,21 +0,0 @@ -# Tags - -| Tag name | PHP Version | Node Version | -|----------|-------------|--------------| -| `latest` | **v8.3.8** | v20.14.0 | -| `php83` | **v8.3.8** | v20.14.0 | -| `php82` | **v8.2.20** | v20.14.0 | -| `php81` | **v8.1.29** | v20.14.0 | -| `php80` | **v8.0.30** | v20.14.0 | - -# Links - -- [PHP](https://hub.docker.com/_/php) Official Image -- [lazerg/laravel](https://hub.docker.com/r/lazerg/laravel) -- [xDebug Setup](https://youtu.be/4opFac50Vwo) - -# xDebug PHPStorm Configuration - -![xDebug PHPStorm Configuration](./assets/php_debug.png) - -![File Bindings](./assets/php_servers.png) \ No newline at end of file diff --git a/assets/php_debug.png b/assets/php_debug.png deleted file mode 100644 index 878f9c3..0000000 Binary files a/assets/php_debug.png and /dev/null differ diff --git a/assets/php_servers.png b/assets/php_servers.png deleted file mode 100644 index 301eab8..0000000 Binary files a/assets/php_servers.png and /dev/null differ diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..ee95bc3 --- /dev/null +++ b/build.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Login to Docker registry +docker login -u "$DOCKER_USER" -p "$DOCKER_PASSWORD" + +# Array of PHP versions +versions=(8.0.30 8.1.29 8.2.20 8.3.8) + +# Iterate through each version +for version in "${versions[@]}"; do + # Extract major and minor version for image tag + major_minor=$(echo "$version" | cut -d '.' -f1,2 | tr -d '.') + + # Define repository name + REPOSITORY="${REPO}:php$major_minor" + + # Build and push image without xdebug + docker build . --file php.Dockerfile \ + --build-arg PHP_VERSION="$version" \ + --build-arg NODE_VERSION=20 \ + --build-arg WITH_XDEBUG=false \ + --no-cache \ + --tag "$REPOSITORY" \ + --push + + # Build and push image with xdebug + docker build . --file php.Dockerfile \ + --build-arg PHP_VERSION="$version" \ + --build-arg NODE_VERSION=20 \ + --build-arg WITH_XDEBUG=true \ + --no-cache \ + --tag "$REPOSITORY"-xdebug \ + --push +done diff --git a/php83.Dockerfile b/php.Dockerfile similarity index 66% rename from php83.Dockerfile rename to php.Dockerfile index 1c770b9..abd416b 100644 --- a/php83.Dockerfile +++ b/php.Dockerfile @@ -1,4 +1,9 @@ -FROM php:8.3.8-fpm +ARG PHP_VERSION=null + +FROM php:${PHP_VERSION}-fpm + +ARG NODE_VERSION=null +ARG WITH_XDEBUG=null # Install dependencies RUN apt-get update @@ -38,16 +43,17 @@ RUN pecl install -o -f redis RUN rm -rf /tmp/pear RUN docker-php-ext-enable redis -# xDebug -RUN pecl install xdebug; -RUN docker-php-ext-enable xdebug; - -# xDebug configuration -RUN echo "zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.mode=develop,debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.discover_client_host=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +RUN if [ "$WITH_XDEBUG" = "true" ]; then \ + # xDebug + pecl install xdebug && \ + docker-php-ext-enable xdebug && \ + # xDebug configuration + echo "zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo "xdebug.mode=develop,debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo "xdebug.discover_client_host=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \ + echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \ + fi # Other PHP extensions RUN docker-php-ext-install pdo_mysql @@ -64,7 +70,7 @@ RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql RUN docker-php-ext-install pdo pdo_pgsql pgsql # Node.js -RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - +RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - RUN apt-get install -y nodejs RUN npm install -g yarn diff --git a/php80.Dockerfile b/php80.Dockerfile deleted file mode 100644 index e9d7b43..0000000 --- a/php80.Dockerfile +++ /dev/null @@ -1,79 +0,0 @@ -FROM php:8.0.30-fpm - -# Install dependencies -RUN apt-get update -RUN apt-get install -y libfreetype6-dev -RUN apt-get install -y libjpeg62-turbo-dev -RUN apt-get install -y libmcrypt-dev -RUN apt-get install -y libpng-dev -RUN apt-get install -y zlib1g-dev -RUN apt-get install -y libxml2-dev -RUN apt-get install -y libzip-dev -RUN apt-get install -y libonig-dev -RUN apt-get install -y graphviz -RUN apt-get install -y libicu-dev -RUN apt-get install -y ghostscript -RUN apt-get install -y supervisor -RUN apt-get install -y dos2unix -RUN apt-get install -y mc -RUN apt-get install -y htop -RUN apt-get install -y nano -RUN apt-get install -y wget -RUN apt-get install -y nginx -RUN apt-get install -y git - -# Composer -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - -# GD extension -RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ -RUN docker-php-ext-install gd - -# Swoole extension -RUN pecl install swoole -RUN docker-php-ext-enable swoole - -# Redis extension -RUN pecl install -o -f redis -RUN rm -rf /tmp/pear -RUN docker-php-ext-enable redis - -# xDebug -RUN pecl install xdebug; -RUN docker-php-ext-enable xdebug; - -# xDebug configuration -RUN echo "zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.mode=develop,debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.discover_client_host=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini - -# Other PHP extensions -RUN docker-php-ext-install pdo_mysql -RUN docker-php-ext-install zip -RUN docker-php-ext-install intl -RUN docker-php-ext-install exif -RUN docker-php-ext-install sockets -RUN docker-php-ext-install pcntl -RUN docker-php-source delete - -# PostgreSQL -RUN apt-get install -y libpq-dev -RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql -RUN docker-php-ext-install pdo pdo_pgsql pgsql - -# Node.js -RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - -RUN apt-get install -y nodejs -RUN npm install -g yarn - -# Aliases -RUN echo "alias 'p=php artisan test'" >> ~/.bashrc -RUN echo "alias 'pf=php artisan test --filter='" >> ~/.bashrc - -WORKDIR /var/www/app/ - -EXPOSE 9000 - -CMD ["php-fpm"] diff --git a/php81.Dockerfile b/php81.Dockerfile deleted file mode 100644 index fce4af8..0000000 --- a/php81.Dockerfile +++ /dev/null @@ -1,79 +0,0 @@ -FROM php:8.1.29-fpm - -# Install dependencies -RUN apt-get update -RUN apt-get install -y libfreetype6-dev -RUN apt-get install -y libjpeg62-turbo-dev -RUN apt-get install -y libmcrypt-dev -RUN apt-get install -y libpng-dev -RUN apt-get install -y zlib1g-dev -RUN apt-get install -y libxml2-dev -RUN apt-get install -y libzip-dev -RUN apt-get install -y libonig-dev -RUN apt-get install -y graphviz -RUN apt-get install -y libicu-dev -RUN apt-get install -y ghostscript -RUN apt-get install -y supervisor -RUN apt-get install -y dos2unix -RUN apt-get install -y mc -RUN apt-get install -y htop -RUN apt-get install -y nano -RUN apt-get install -y wget -RUN apt-get install -y nginx -RUN apt-get install -y git - -# Composer -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - -# GD extension -RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ -RUN docker-php-ext-install gd - -# Swoole extension -RUN pecl install swoole -RUN docker-php-ext-enable swoole - -# Redis extension -RUN pecl install -o -f redis -RUN rm -rf /tmp/pear -RUN docker-php-ext-enable redis - -# xDebug -RUN pecl install xdebug; -RUN docker-php-ext-enable xdebug; - -# xDebug configuration -RUN echo "zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.mode=develop,debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.discover_client_host=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini - -# Other PHP extensions -RUN docker-php-ext-install pdo_mysql -RUN docker-php-ext-install zip -RUN docker-php-ext-install intl -RUN docker-php-ext-install exif -RUN docker-php-ext-install sockets -RUN docker-php-ext-install pcntl -RUN docker-php-source delete - -# PostgreSQL -RUN apt-get install -y libpq-dev -RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql -RUN docker-php-ext-install pdo pdo_pgsql pgsql - -# Node.js -RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - -RUN apt-get install -y nodejs -RUN npm install -g yarn - -# Aliases -RUN echo "alias 'p=php artisan test'" >> ~/.bashrc -RUN echo "alias 'pf=php artisan test --filter='" >> ~/.bashrc - -WORKDIR /var/www/app/ - -EXPOSE 9000 - -CMD ["php-fpm"] diff --git a/php82.Dockerfile b/php82.Dockerfile deleted file mode 100644 index 1ea630a..0000000 --- a/php82.Dockerfile +++ /dev/null @@ -1,79 +0,0 @@ -FROM php:8.2.20-fpm - -# Install dependencies -RUN apt-get update -RUN apt-get install -y libfreetype6-dev -RUN apt-get install -y libjpeg62-turbo-dev -RUN apt-get install -y libmcrypt-dev -RUN apt-get install -y libpng-dev -RUN apt-get install -y zlib1g-dev -RUN apt-get install -y libxml2-dev -RUN apt-get install -y libzip-dev -RUN apt-get install -y libonig-dev -RUN apt-get install -y graphviz -RUN apt-get install -y libicu-dev -RUN apt-get install -y ghostscript -RUN apt-get install -y supervisor -RUN apt-get install -y dos2unix -RUN apt-get install -y mc -RUN apt-get install -y htop -RUN apt-get install -y nano -RUN apt-get install -y wget -RUN apt-get install -y nginx -RUN apt-get install -y git - -# Composer -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer - -# GD extension -RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ -RUN docker-php-ext-install gd - -# Swoole extension -RUN pecl install swoole -RUN docker-php-ext-enable swoole - -# Redis extension -RUN pecl install -o -f redis -RUN rm -rf /tmp/pear -RUN docker-php-ext-enable redis - -# xDebug -RUN pecl install xdebug; -RUN docker-php-ext-enable xdebug; - -# xDebug configuration -RUN echo "zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.mode=develop,debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.discover_client_host=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -RUN echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini - -# Other PHP extensions -RUN docker-php-ext-install pdo_mysql -RUN docker-php-ext-install zip -RUN docker-php-ext-install intl -RUN docker-php-ext-install exif -RUN docker-php-ext-install sockets -RUN docker-php-ext-install pcntl -RUN docker-php-source delete - -# PostgreSQL -RUN apt-get install -y libpq-dev -RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql -RUN docker-php-ext-install pdo pdo_pgsql pgsql - -# Node.js -RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - -RUN apt-get install -y nodejs -RUN npm install -g yarn - -# Aliases -RUN echo "alias 'p=php artisan test'" >> ~/.bashrc -RUN echo "alias 'pf=php artisan test --filter='" >> ~/.bashrc - -WORKDIR /var/www/app/ - -EXPOSE 9000 - -CMD ["php-fpm"]