Skip to content

Commit 5f4f9b0

Browse files
author
DKravtsov
committed
refactoring environment, updated composer dependencies
1 parent 5577ee0 commit 5f4f9b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2620
-3433
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ reports/*
88
/.env.*.local
99
/config/secrets/prod/prod.decrypt.private.php
1010
/public/bundles/
11-
/var/
11+
/var/*
12+
!var/.gitkeep
1213
/vendor/
1314
/tools/**/vendor
1415
###< symfony/framework-bundle ###

Dockerfile

+19-13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ ENV DEBUG_ENABLED=$BUILD_ARGUMENT_DEBUG_ENABLED
66
ARG BUILD_ARGUMENT_ENV=dev
77
ENV ENV=$BUILD_ARGUMENT_ENV
88
ENV APP_HOME /var/www/html
9+
ARG UID=1000
10+
ARG GID=1000
11+
ENV USERNAME=www-data
912

1013
# check environment
1114
RUN if [ "$BUILD_ARGUMENT_ENV" = "default" ]; then echo "Set BUILD_ARGUMENT_ENV in docker build-args like --build-arg BUILD_ARGUMENT_ENV=dev" && exit 2; \
@@ -29,7 +32,9 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \
2932
libreadline-dev \
3033
supervisor \
3134
cron \
35+
sudo \
3236
libzip-dev \
37+
wget \
3338
librabbitmq-dev \
3439
&& pecl install amqp \
3540
&& docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \
@@ -50,12 +55,12 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \
5055
RUN a2dissite 000-default.conf
5156
RUN rm -r $APP_HOME
5257

53-
# create document root
54-
RUN mkdir -p $APP_HOME/public
55-
56-
# change uid and gid of apache to docker user uid/gid
57-
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data
58-
RUN chown -R www-data:www-data $APP_HOME
58+
# create document root, fix permissions for www-data user and change owner to www-data
59+
RUN mkdir -p $APP_HOME/public && \
60+
mkdir -p /home/$USERNAME && chown $USERNAME:$USERNAME /home/$USERNAME \
61+
&& usermod -u $UID $USERNAME -d /home/$USERNAME \
62+
&& groupmod -g $GID $USERNAME \
63+
&& chown -R ${USERNAME}:${USERNAME} $APP_HOME
5964

6065
# put apache and php config for Symfony, enable sites
6166
COPY ./docker/general/symfony.conf /etc/apache2/sites-available/symfony.conf
@@ -67,11 +72,15 @@ COPY ./docker/$BUILD_ARGUMENT_ENV/php.ini /usr/local/etc/php/php.ini
6772
RUN a2enmod rewrite
6873
RUN a2enmod ssl
6974

70-
# install Xdebug in case development or test environment
75+
# install Xdebug in case dev/test environment
7176
COPY ./docker/general/do_we_need_xdebug.sh /tmp/
7277
COPY ./docker/dev/xdebug.ini /tmp/
7378
RUN chmod u+x /tmp/do_we_need_xdebug.sh && /tmp/do_we_need_xdebug.sh
7479

80+
# install security-checker in case dev/test environment
81+
COPY ./docker/general/do_we_need_security-checker.sh /tmp/
82+
RUN chmod u+x /tmp/do_we_need_security-checker.sh && /tmp/do_we_need_security-checker.sh
83+
7584
# install composer
7685
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
7786
RUN chmod +x /usr/bin/composer
@@ -80,7 +89,7 @@ ENV COMPOSER_ALLOW_SUPERUSER 1
8089
# add supervisor
8190
RUN mkdir -p /var/log/supervisor
8291
COPY --chown=root:root ./docker/general/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
83-
COPY --chown=root:root ./docker/general/cron /var/spool/cron/crontabs/root
92+
COPY --chown=root:crontab ./docker/general/cron /var/spool/cron/crontabs/root
8493
RUN chmod 0600 /var/spool/cron/crontabs/root
8594

8695
# generate certificates
@@ -90,13 +99,10 @@ RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private
9099
# set working directory
91100
WORKDIR $APP_HOME
92101

93-
# create composer folder for user www-data
94-
RUN mkdir -p /var/www/.composer && chown -R www-data:www-data /var/www/.composer
95-
96-
USER www-data
102+
USER ${USERNAME}
97103

98104
# copy source files
99-
COPY --chown=www-data:www-data . $APP_HOME/
105+
COPY --chown=${USERNAME}:${USERNAME} . $APP_HOME/
100106

101107
# install all PHP dependencies
102108
RUN if [ "$BUILD_ARGUMENT_ENV" = "dev" ] || [ "$BUILD_ARGUMENT_ENV" = "test" ]; then COMPOSER_MEMORY_LIMIT=-1 composer install --optimize-autoloader --no-interaction --no-progress; \

Makefile

+9-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ifndef APP_ENV
88
endif
99
endif
1010

11+
symfony_user=-u www-data
1112
project=-p ${COMPOSE_PROJECT_NAME}
1213
service=${COMPOSE_PROJECT_NAME}:latest
1314
openssl_bin:=$(shell which openssl)
@@ -68,7 +69,7 @@ env-staging:
6869
@make exec cmd="composer dump-env staging"
6970

7071
ssh:
71-
@docker-compose $(project) exec $(optionT) symfony bash
72+
@docker-compose $(project) exec $(optionT) $(symfony_user) symfony bash
7273

7374
ssh-supervisord:
7475
@docker-compose $(project) exec supervisord bash
@@ -80,10 +81,13 @@ ssh-rabbitmq:
8081
@docker-compose $(project) exec rabbitmq /bin/sh
8182

8283
exec:
83-
@docker-compose $(project) exec $(optionT) symfony $$cmd
84+
@docker-compose $(project) exec $(optionT) $(symfony_user) symfony $$cmd
8485

8586
exec-bash:
86-
@docker-compose $(project) exec $(optionT) symfony bash -c "$(cmd)"
87+
@docker-compose $(project) exec $(optionT) $(symfony_user) symfony bash -c "$(cmd)"
88+
89+
exec-by-root:
90+
@docker-compose $(project) exec $(optionT) symfony $$cmd
8791

8892
report-prepare:
8993
mkdir -p $(dir)/reports/coverage
@@ -160,7 +164,7 @@ ecs-fix: ## Run The Easy Coding Standard to fix issues
160164

161165
###> phpmetrics ###
162166
phpmetrics:
163-
@make exec cmd="make phpmetrics-process"
167+
@make exec-by-root cmd="make phpmetrics-process"
164168

165169
phpmetrics-process: ## Generates PhpMetrics static analysis, should be run inside symfony container
166170
@mkdir -p reports/phpmetrics
@@ -170,7 +174,7 @@ phpmetrics-process: ## Generates PhpMetrics static analysis, should be run insid
170174
fi;
171175
@echo "\033[32mRunning PhpMetrics\033[39m"
172176
@php ./vendor/bin/phpmetrics --version
173-
@./vendor/bin/phpmetrics --junit=reports/junit.xml --report-html=reports/phpmetrics .
177+
@php ./vendor/bin/phpmetrics --junit=reports/junit.xml --report-html=reports/phpmetrics .
174178
###< phpmetrics ###
175179

176180
###> php copy/paste detector ###

composer.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"ext-pdo": "*",
3333
"ext-pdo_mysql": "*",
3434
"doctrine/doctrine-migrations-bundle": "^3.0",
35-
"easycorp/easy-log-handler": "1.0.*",
35+
"systemsdk/easy-log-bundle": "1.10.*",
3636
"jmose/command-scheduler-bundle": "^3.0",
3737
"sensio/framework-extra-bundle": "^5.6",
3838
"symfony/apache-pack": "^1.0",
@@ -77,7 +77,6 @@
7777
"doctrine/doctrine-fixtures-bundle": "^3.4",
7878
"ergebnis/composer-normalize": "^2.13",
7979
"roave/security-advisories": "dev-master",
80-
"sensiolabs/security-checker": "^6.0",
8180
"symfony/debug-bundle": "4.4.*",
8281
"symfony/maker-bundle": "^1.26",
8382
"symfony/requirements-checker": "^2.0",
@@ -125,14 +124,14 @@
125124
"scripts": {
126125
"post-install-cmd": [
127126
"if test -d vendor/symfony/requirements-checker; then ./vendor/bin/requirements-checker; fi",
128-
"if test -d vendor/sensiolabs/security-checker; then ./vendor/bin/security-checker security:check; fi",
129127
"if test -d vendor/bamarni/composer-bin-plugin; then composer bin all install; fi",
128+
"if which local-php-security-checker; then local-php-security-checker --update-cache && local-php-security-checker; fi",
130129
"@auto-scripts"
131130
],
132131
"post-update-cmd": [
133132
"if test -d vendor/symfony/requirements-checker; then ./vendor/bin/requirements-checker; fi",
134-
"if test -d vendor/sensiolabs/security-checker; then ./vendor/bin/security-checker security:check; fi",
135133
"if test -d vendor/bamarni/composer-bin-plugin; then composer bin all update; fi",
134+
"if which local-php-security-checker; then local-php-security-checker --update-cache && local-php-security-checker; fi",
136135
"@auto-scripts"
137136
],
138137
"auto-scripts": {

0 commit comments

Comments
 (0)