Skip to content

Commit 0a4e1fa

Browse files
committed
app Dockerfile, docker-compose conf dist, xdebug setup
1 parent d79413c commit 0a4e1fa

File tree

9 files changed

+98
-2
lines changed

9 files changed

+98
-2
lines changed

.env.dev.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010

1111
COMPOSE_PROJECT_NAME=reactphp_foundation
1212

13+
TIMEZONE=Europe/Moscow
14+
SOURCE_PATH=.
15+
DEPLOYMENT_PATH=/var/www/foundation
16+
17+
# php
18+
PHP_VERSION=7.4
19+
1320
# app
1421
APP_ENV=dev
1522
APP_SERVER_PORT=6636
23+
APP_SERVER_PORT_EXPOSE=6636

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.idea/
22

33
.env
4+
docker-compose.yml
45

56
vendor/
67

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ with `.env` and `parameters.yml` support.
1818
- Main `Application` class that starts
1919
the async socket server and the event loop.
2020
- `ServerInterface` and the `HandlerInterface`, example handler implementation.
21-
- Non-blocking logger (based on [wyrihaximus/react-psr-3-stdio](https://github.com/WyriHaximus/reactphp-psr-3-stdio))
21+
- Non-blocking logger (based on [wyrihaximus/react-psr-3-stdio](https://github.com/WyriHaximus/reactphp-psr-3-stdio)).
2222

2323
[Unreleased]: https://github.com/itnelo/reactphp-foundation/compare/0.1.0...0.x
2424
[0.2.0]: https://github.com/itnelo/reactphp-foundation/compare/0.1.0..0.2.0

config/async/server.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ services:
2020
react.socket.tcp_server:
2121
class: React\Socket\TcpServer
2222
arguments:
23-
- '%app.server.port%'
23+
- '%app.server.host%:%app.server.port%'
2424
- '@react.event_loop.stream_select'

config/parameters.yml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ parameters:
55
app.locale: en
66

77
# Socket server configuration
8+
app.server.host: 'tcp://0.0.0.0'
89
app.server.port: '%env(int:APP_SERVER_PORT)%'

docker-compose.dev.yml.dist

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
# This file is part of the ReactPHP Foundation <https://github.com/itnelo/reactphp-foundation>.
3+
#
4+
# (c) 2020 Pavel Petrov <itnelo@gmail.com>.
5+
#
6+
# For the full copyright and license information, please view the LICENSE
7+
# file that was distributed with this source code.
8+
#
9+
# @license https://opensource.org/licenses/mit MIT
10+
11+
version: '3'
12+
13+
services:
14+
app:
15+
build:
16+
context: ./docker/${APP_ENV}/app
17+
args:
18+
PHP_VERSION: ${PHP_VERSION}
19+
TIMEZONE: ${TIMEZONE}
20+
DEPLOYMENT_PATH: ${DEPLOYMENT_PATH}
21+
APP_SERVER_PORT_EXPOSE: ${APP_SERVER_PORT_EXPOSE}
22+
networks:
23+
- back
24+
ports:
25+
- "${APP_SERVER_PORT_EXPOSE}:${APP_SERVER_PORT}"
26+
volumes:
27+
- ${SOURCE_PATH}:${DEPLOYMENT_PATH}
28+
29+
networks:
30+
# Debugging example:
31+
# docker-compose run -p 6636:6636 --rm app -d xdebug.remote_autostart=1 -d xdebug.remote_host=172.110.0.1 bin/app
32+
# you can also try more convenient "host.docker.internal" for some systems.
33+
back:
34+
driver: bridge
35+
ipam:
36+
driver: default
37+
config:
38+
- subnet: 172.110.0.0/16
39+
gateway: 172.110.0.1

docker/dev/app/Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
# This file is part of the ReactPHP Foundation <https://github.com/itnelo/reactphp-foundation>.
3+
#
4+
# (c) 2020 Pavel Petrov <itnelo@gmail.com>.
5+
#
6+
# For the full copyright and license information, please view the LICENSE
7+
# file that was distributed with this source code.
8+
#
9+
# @license https://opensource.org/licenses/mit MIT
10+
11+
ARG PHP_VERSION
12+
13+
FROM php:${PHP_VERSION}-cli
14+
15+
ARG TIMEZONE
16+
ARG DEPLOYMENT_PATH
17+
ARG APP_SERVER_PORT_EXPOSE
18+
19+
WORKDIR ${DEPLOYMENT_PATH}
20+
21+
USER root
22+
23+
# timezone
24+
RUN ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && echo ${TIMEZONE} > /etc/timezone && \
25+
printf '[PHP]\ndate.timezone = "%s"\n', ${TIMEZONE} > /usr/local/etc/php/conf.d/tzone.ini && \
26+
date
27+
28+
# xdebug
29+
RUN pecl install xdebug-beta && docker-php-ext-enable xdebug
30+
COPY docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
31+
32+
COPY php.ini /usr/local/etc/php/conf.d/php.ini
33+
34+
# composer
35+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
36+
composer --version
37+
38+
USER www-data
39+
40+
EXPOSE ${APP_SERVER_PORT_EXPOSE}/tcp
41+
42+
CMD ["bin/app"]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
zend_extension = xdebug.so
2+
xdebug.remote_enable = 1
3+
xdebug.idekey = "PHPSTORM"
4+
xdebug.remote_port = 9000

docker/dev/app/php.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
memory_limit = 1024M

0 commit comments

Comments
 (0)