Skip to content

Commit

Permalink
Merge pull request #5 from artem328/4.2
Browse files Browse the repository at this point in the history
4.2
  • Loading branch information
etomilin authored Feb 21, 2019
2 parents b7eb88d + f58de28 commit 50160a9
Show file tree
Hide file tree
Showing 16 changed files with 197 additions and 51 deletions.
8 changes: 7 additions & 1 deletion .env.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Docker configuration
SERVER_HTTP_PORT=80
HOST_UID=
EXTERNAL_HTTP_PORT=80
EXTERNAL_POSTGRES_PORT=5432
# PHP_IDE_CONFIG is necessary for xDebug
# Create server mapping in PHPStorm with name Default
# or change serverName value to appropriate one
PHP_IDE_CONFIG=serverName=Default

# Postgres credentials
POSTGRES_PASSWORD=dev
Expand Down
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
.idea
.idea/

# Make .env untracked and follow old rules of .env files:
# - .env.dist file contains example values
# - .env file is used for project and for docker-compose as well
# The reason of it is docker look into .env file for variables used in config
# and will not check .env.local, .env.${ENV} etc.
# Also we cannot configure docker-compose to get variables from files different from .env
.env
5 changes: 5 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ return PhpCsFixer\Config::create()
'@DoctrineAnnotation' => true,
'phpdoc_order' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_class_elements' => true,
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => [
'only_untyped' => false,
],
])
->setFinder($finder)
;
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ in 4xxi for developing majority of the projects. It contains bare Symfony Skelet
* MonologBundle
* Sensiolabs SecurityChecker
* A set of bundles and tools that are necessary for development
* [Maker Bundle](https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html)
* [PHP CS Fixer](https://cs.sensiolabs.org/)
* [Deployer](https://deployer.org/)
* Debug Pack (Debug + Profiler + Dumper)
Expand Down Expand Up @@ -93,7 +92,7 @@ Application configuration is stored in `.env` file.

### HTTP port
If you have nginx or apache installed and using 80 port on host system you can either stop them before proceeding or
reconfigure Docker to use another port by changing value of `SERVER_HTTP_PORT` in `.env` file.
reconfigure Docker to use another port by changing value of `EXTERNAL_HTTP_PORT` in `.env` file.

### Application environment
You can change application environment to `dev` of `prod` by changing `APP_ENV` variable in `.env` file.
Expand Down Expand Up @@ -152,4 +151,4 @@ docker-compose exec php vendor/bin/php-cs-fixer fix
Run PHP Unit Tests:
```bash
docker-compose exec php bin/phpunit
```
```
31 changes: 16 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@
"type": "project",
"license": "MIT",
"require": {
"php": "^7.1.3",
"php": "^7.3",
"ext-iconv": "*",
"sensio/framework-extra-bundle": "^5.2",
"sensiolabs/security-checker": "^4.1",
"symfony/console": "^4.1",
"symfony/flex": "^1.0",
"symfony/framework-bundle": "^4.1",
"symfony/lts": "^4@dev",
"symfony/monolog-bundle": "^3.3",
"symfony/orm-pack": "^1.0",
"symfony/yaml": "^4.1"
"sensio/framework-extra-bundle": "~5.2.0",
"sensiolabs/security-checker": "~5.0.0",
"symfony/console": "~4.2.0",
"symfony/flex": "~1.1.0",
"symfony/framework-bundle": "~4.2.0",
"symfony/monolog-bundle": "~3.3.0",
"symfony/orm-pack": "~1.0.0",
"symfony/yaml": "~4.2.0",
"symfony/dotenv": "~4.2.0"
},
"require-dev": {
"deployer/deployer": "^6.2",
"friendsofphp/php-cs-fixer": "^2.0",
"symfony/debug-pack": "^1.0",
"symfony/dotenv": "^4.1",
"symfony/maker-bundle": "^1.5"
"deployer/deployer": "^6.4",
"friendsofphp/php-cs-fixer": "^2.14",
"symfony/debug-pack": "^1.0"
},
"suggest": {
"symfony/maker-bundle": "To have an ability of simple creation of common classes via console."
},
"config": {
"preferred-install": {
Expand Down
2 changes: 1 addition & 1 deletion config/deployer/hosts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ dev:
# deploy_path: /var/www/domain.com # Replace with proper deploy path
# branch: master
# user: deploy
# stage: prod
# stage: prod
10 changes: 0 additions & 10 deletions config/docker/docker-entrypoint.sh

This file was deleted.

53 changes: 44 additions & 9 deletions config/docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
FROM 4xxi/php-pgsql:flex
FROM php:7.3-fpm-alpine

# To add additional packages and php extensions uncomment the following lines and add required dependencies
# Check https://hub.docker.com/_/php/ for examples and documentation
RUN apk add --no-cache \
git \
icu-dev \
libzip-dev \
postgresql-dev \
zip

#RUN apt-get update && apt-get install -y \
# lib_name_1 \
# lib_name_2 \
# && docker-php-ext-install \
# ext_name_1 \
# ext_name_2
RUN docker-php-ext-install \
intl \
opcache \
pdo \
pdo_pgsql \
zip

# Uncomment code below for enabling xDebug
# or delete it with the xdebug.ini file

#RUN apk add --no-cache --virtual .xdebug-build-deps ${PHPIZE_DEPS} \
# && pecl install xdebug \
# && docker-php-ext-enable xdebug \
# && apk del .xdebug-build-deps
#
#COPY xdebug.ini /usr/local/etc/php/xdebug.ini
#
#RUN cat /usr/local/etc/php/xdebug.ini >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

COPY --from=composer /usr/bin/composer /usr/bin/composer

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_MEMORY_LIMIT -1
RUN composer global require hirak/prestissimo --no-plugins --no-scripts

ARG HOST_UID

RUN if [ ! -z "${HOST_UID}" ]; then \
deluser www-data \
&& addgroup www-data \
&& adduser -u "${HOST_UID}" -G www-data -H -s /bin/sh -D www-data; \
fi

ENV WWW_DATA_UID ${HOST_UID}

COPY ./symfony.ini /usr/local/etc/php/conf.d/
COPY ./symfony.pool.conf /usr/local/etc/php-fpm.d/
20 changes: 20 additions & 0 deletions config/docker/php/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

COMMAND="composer install --prefer-dist --no-progress --no-suggest --no-interaction"

if [[ "prod" = "${APP_ENV}" ]]; then
COMMAND="${COMMAND} --no-dev --optimize-autoloader --classmap-authoritative"
fi

if [[ ! -z "${WWW_DATA_UID}" ]]; then
su \
-c "${COMMAND}" \
-s /bin/sh \
-m \
www-data
else
${COMMAND}
chown -R www-data var/
fi

php-fpm
3 changes: 3 additions & 0 deletions config/docker/php/symfony.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
date.timezone = UTC
memory_limit = -1
max_execution_time=3000
69 changes: 69 additions & 0 deletions config/docker/php/symfony.pool.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 0.0.0.0:9000

; Choose how the process manager will control the number of child processes.
; Possible Values:
; static - a fixed number (pm.max_children) of child processes;
; dynamic - the number of child processes are set dynamically based on the
; following directives. With this process management, there will be
; always at least 1 children.
; pm.max_children - the maximum number of children that can
; be alive at the same time.
; pm.start_servers - the number of children created on startup.
; pm.min_spare_servers - the minimum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is less than this
; number then some children will be created.
; pm.max_spare_servers - the maximum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is greater than this
; number then some children will be killed.
; ondemand - no children are created at startup. Children will be forked when
; new requests will connect. The following parameter are used:
; pm.max_children - the maximum number of children that
; can be alive at the same time.
; pm.process_idle_timeout - The number of seconds after which
; an idle process will be killed.
; Note: This value is mandatory.
pm = dynamic

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 20

; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 2

; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 1

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 3

catch_workers_output = yes
4 changes: 4 additions & 0 deletions config/docker/php/xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
xdebug.remote_enable=on
xdebug.remote_autostart=on
xdebug.remote_connect_back=1
xdebug.remote_port=9000
6 changes: 2 additions & 4 deletions config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ parameters:

doctrine:
dbal:
# configure these for your database server
driver: 'pdo_pgsql'
server_version: '9.6'
server_version: '10.6'

# With Symfony 3.3, remove the `resolve:` prefix
url: '%env(resolve:DATABASE_URL)%'
url: '%env(DATABASE_URL)%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ services:

volumes:
project_name-data-sync: # Replace project_name with the name of your project
external: true
external: true
18 changes: 13 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,35 @@ version: '3.2'

services:
php:
build: ./config/docker/php
build:
context: ./config/docker/php
args:
- HOST_UID=${HOST_UID}
depends_on:
- db
working_dir: /var/www/html
volumes:
- .:/var/www/html
expose:
- "9000"
entrypoint: ./config/docker/docker-entrypoint.sh
entrypoint: ./config/docker/php/docker-entrypoint.sh
environment:
- COMPOSER_HOME=/var/www/html/var/composer
- PHP_IDE_CONFIG
- APP_ENV
nginx:
image: 4xxi/nginx:flex
depends_on:
- php
ports:
- "${SERVER_HTTP_PORT}:80"
- "${EXTERNAL_HTTP_PORT}:80"
volumes:
- .:/var/www/html
- ./var/log:/var/log/nginx
db:
image: postgres:9
image: postgres:10.6
ports:
- "5432:5432"
- "${EXTERNAL_POSTGRES_PORT}:5432"
volumes:
- db:/var/lib/postgresql/data
environment:
Expand Down
2 changes: 1 addition & 1 deletion docker-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ syncs:
sync_excludes:
- '.git'
- '.idea'
- 'var/cache/*'
- 'var/cache/*'

0 comments on commit 50160a9

Please sign in to comment.