Skip to content

Commit 08840db

Browse files
authored
Add docker compose for development (#33)
* add docker compose for different php versions
1 parent 62d97f7 commit 08840db

4 files changed

Lines changed: 72 additions & 1 deletion

File tree

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
php-versions: ['7.4', '8.0', '8.1']
18+
php-versions: ['7.4', '8.0', '8.1', '8.2']
1919
steps:
2020
- uses: actions/checkout@v3
2121

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
ARG PHP_VERSION
2+
ARG ALPINE_VERSION=3.18
3+
4+
FROM php:${PHP_VERSION}-cli-alpine${ALPINE_VERSION}
5+
6+
ARG DOCKER_USER_ID=1001
7+
ARG DOCKER_GROUP_ID=1001
8+
ARG PHP_XDEBUG_VERSION
9+
10+
# https://blog.codito.dev/2022/11/composer-binary-only-docker-images/
11+
COPY --from=composer/composer:2-bin /composer /usr/local/bin/composer
12+
13+
RUN if ! getent group "${DOCKER_GROUP_ID}" > /dev/null; \
14+
then addgroup -S -g "${DOCKER_GROUP_ID}" devs; \
15+
fi \
16+
&& if ! getent passwd "${DOCKER_USER_ID}" > /dev/null; \
17+
then adduser -S -u "${DOCKER_USER_ID}" -G "$(getent group "${DOCKER_GROUP_ID}" | awk -F: '{printf $1}')" dev; \
18+
fi \
19+
# php extensions
20+
&& curl --location --output /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions \
21+
&& chmod +x /usr/local/bin/install-php-extensions \
22+
&& sync \
23+
&& install-php-extensions \
24+
pcntl \
25+
xdebug-${PHP_XDEBUG_VERSION} \
26+
# xdebug command
27+
&& curl --location --output /usr/local/bin/xdebug https://github.com/julienfalque/xdebug/releases/download/v2.0.0/xdebug \
28+
&& chmod +x /usr/local/bin/xdebug
29+
30+
COPY docker/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

docker-compose.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: '3.8'
2+
3+
services:
4+
php-7.4: &php
5+
build:
6+
args:
7+
ALPINE_VERSION: "3.16"
8+
PHP_VERSION: "7.4"
9+
PHP_XDEBUG_VERSION: "3.1.2"
10+
working_dir: /app
11+
volumes:
12+
- .:/app
13+
environment:
14+
PHP_IDE_CONFIG: serverName=php-text-parser
15+
php-8.0:
16+
<<: *php
17+
build:
18+
args:
19+
PHP_VERSION: "8.0"
20+
php-8.1:
21+
<<: *php
22+
build:
23+
args:
24+
PHP_VERSION: "8.1"
25+
php-8.2:
26+
<<: *php
27+
build:
28+
args:
29+
PHP_VERSION: "8.2"
30+
PHP_XDEBUG_VERSION: "3.2.1"

docker/xdebug.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; XDebug 3 → https://xdebug.org/docs/upgrade_guide
2+
; You can dynamically enable XDebug by setting XDEBUG_MODE env variable.
3+
; Some options can be dynamically overridden with XDEBUG_CONFIG env variable.
4+
xdebug.mode = off
5+
xdebug.start_with_request = yes
6+
xdebug.discover_client_host = true
7+
xdebug.client_host = host.docker.internal
8+
9+
; Required so XDebug DOES NOT print warning "Could not connect to debugging client"
10+
xdebug.log = /app/docker/php/xdebug.log
11+
xdebug.log_level = 1

0 commit comments

Comments
 (0)