Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Optional xDebug. #4

Merged
merged 9 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
75 changes: 0 additions & 75 deletions .github/workflows/php.yml

This file was deleted.

21 changes: 0 additions & 21 deletions README.MD

This file was deleted.

Binary file removed assets/php_debug.png
Binary file not shown.
Binary file removed assets/php_servers.png
Binary file not shown.
34 changes: 34 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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
30 changes: 18 additions & 12 deletions php83.Dockerfile → php.Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
79 changes: 0 additions & 79 deletions php80.Dockerfile

This file was deleted.

79 changes: 0 additions & 79 deletions php81.Dockerfile

This file was deleted.

Loading
Loading