Skip to content

Commit 7c133ae

Browse files
committed
Add standard Docker setup.
1 parent fe02948 commit 7c133ae

File tree

7 files changed

+69
-0
lines changed

7 files changed

+69
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ vendor
33
composer.lock
44
coverage
55
.phpunit.result.cache
6+
.env

Makefile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
compose_command = docker-compose run -u $(id -u ${USER}):$(id -g ${USER}) --rm php81
2+
3+
build:
4+
docker-compose build
5+
6+
shell: build
7+
$(compose_command) bash
8+
9+
destroy:
10+
docker-compose down -v
11+
12+
composer: build
13+
$(compose_command) composer install
14+
15+
test: build
16+
$(compose_command) vendor/bin/phpunit
17+

default-.env

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# See https://docs.docker.com/compose/env-file/
2+
3+
# global configuration
4+
# For production
5+
#COMPOSE_FILE=docker-compose.yml
6+
# For local dev
7+
#COMPOSE_FILE=docker-compose.yml:docker-compose.override.yml
8+
# For local dev with tunnel
9+
10+
COMPOSE_FILE=docker-compose.yml
11+
# Ip of the host that docker can reach
12+
HOST_IP=172.17.0.1
13+
# Xdebug IDE key
14+
IDE_KEY=docker-xdebug
15+
# Port your IDE is listening on
16+
XDEBUG_PORT=9003

docker-compose.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# To use:
2+
# Run "docker-compose build" to rebuild the app container.
3+
# Run "docker-compose run -u $(id -u ${USER}):$(id -g ${USER}) --rm php81 composer install" to install dependencies.
4+
# Run "docker-compose run -u $(id -u ${USER}):$(id -g ${USER})--rm php81 vendor/bin/phpunit" to run the test script on 8.1.
5+
# Run "docker-compose down -v" to fully wipe everything and start over.
6+
# Run "docker-compose run -u $(id -u ${USER}):$(id -g ${USER}) --rm php80 bash" to log into the container to run tests selectively.
7+
8+
version: "3"
9+
services:
10+
php81:
11+
build: ./docker/php/81
12+
volumes:
13+
- ~/.composer:/.composer #uncomment this line to allow usage of local composer cache
14+
- .:/usr/src/myapp
15+
- ./docker/php/81/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
16+
- ./docker/php/conf.d/error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini
17+
environment:
18+
XDEBUG_MODE: "develop,debug"
19+
XDEBUG_CONFIG: "client_host=${HOST_IP} idekey=${IDE_KEY} client_port=${XDEBUG_PORT} discover_client_host=1 start_with_request=1"

docker/php/81/Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM php:8.1.1-cli
2+
WORKDIR /usr/src/myapp
3+
4+
RUN apt-get update && apt-get install zip unzip git -y \
5+
&& pecl install xdebug \
6+
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
7+
&& php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
8+
&& php composer-setup.php --install-dir=/usr/bin --filename=composer \
9+
&& php -r "unlink('composer-setup.php');" \
10+
&& mkdir /.composer && chmod 777 /.composer

docker/php/81/xdebug.ini

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20210902/xdebug.so
2+
xdebug.output_dir=profiles

docker/php/conf.d/error_reporting.ini

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
error_reporting=E_ALL
2+
; By default this is GPCS - we also want E so that $_ENV would be populated, and
3+
; we could trigger Xdebug using an environment variable on the command line.
4+
variables_order = "EGPCS"

0 commit comments

Comments
 (0)