Skip to content

Commit

Permalink
Add docker compose for development (#33)
Browse files Browse the repository at this point in the history
* add docker compose for different php versions
  • Loading branch information
aymanrb committed Jul 2, 2023
1 parent 62d97f7 commit 08840db
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.4', '8.0', '8.1']
php-versions: ['7.4', '8.0', '8.1', '8.2']
steps:
- uses: actions/checkout@v3

Expand Down
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ARG PHP_VERSION
ARG ALPINE_VERSION=3.18

FROM php:${PHP_VERSION}-cli-alpine${ALPINE_VERSION}

ARG DOCKER_USER_ID=1001
ARG DOCKER_GROUP_ID=1001
ARG PHP_XDEBUG_VERSION

# https://blog.codito.dev/2022/11/composer-binary-only-docker-images/
COPY --from=composer/composer:2-bin /composer /usr/local/bin/composer

RUN if ! getent group "${DOCKER_GROUP_ID}" > /dev/null; \
then addgroup -S -g "${DOCKER_GROUP_ID}" devs; \
fi \
&& if ! getent passwd "${DOCKER_USER_ID}" > /dev/null; \
then adduser -S -u "${DOCKER_USER_ID}" -G "$(getent group "${DOCKER_GROUP_ID}" | awk -F: '{printf $1}')" dev; \
fi \
# php extensions
&& curl --location --output /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions \
&& chmod +x /usr/local/bin/install-php-extensions \
&& sync \
&& install-php-extensions \
pcntl \
xdebug-${PHP_XDEBUG_VERSION} \
# xdebug command
&& curl --location --output /usr/local/bin/xdebug https://github.com/julienfalque/xdebug/releases/download/v2.0.0/xdebug \
&& chmod +x /usr/local/bin/xdebug

COPY docker/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: '3.8'

services:
php-7.4: &php
build:
args:
ALPINE_VERSION: "3.16"
PHP_VERSION: "7.4"
PHP_XDEBUG_VERSION: "3.1.2"
working_dir: /app
volumes:
- .:/app
environment:
PHP_IDE_CONFIG: serverName=php-text-parser
php-8.0:
<<: *php
build:
args:
PHP_VERSION: "8.0"
php-8.1:
<<: *php
build:
args:
PHP_VERSION: "8.1"
php-8.2:
<<: *php
build:
args:
PHP_VERSION: "8.2"
PHP_XDEBUG_VERSION: "3.2.1"
11 changes: 11 additions & 0 deletions docker/xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
; XDebug 3 → https://xdebug.org/docs/upgrade_guide
; You can dynamically enable XDebug by setting XDEBUG_MODE env variable.
; Some options can be dynamically overridden with XDEBUG_CONFIG env variable.
xdebug.mode = off
xdebug.start_with_request = yes
xdebug.discover_client_host = true
xdebug.client_host = host.docker.internal

; Required so XDebug DOES NOT print warning "Could not connect to debugging client"
xdebug.log = /app/docker/php/xdebug.log
xdebug.log_level = 1

0 comments on commit 08840db

Please sign in to comment.