Skip to content

Commit 60dcca6

Browse files
author
DKravtsov
committed
refactoring environment, updated composer dependencies
1 parent bef1a76 commit 60dcca6

Some content is hidden

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

48 files changed

+2816
-3625
lines changed

.circleci/config.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ version: 2
22
jobs:
33
build:
44
working_directory: ~/html
5-
machine: true
5+
machine:
6+
image: ubuntu-2004:202101-01
67
branches:
78
ignore:
89
- develop

.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-11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ 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
12+
913

1014
# check environment
1115
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 +33,9 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \
2933
libreadline-dev \
3034
supervisor \
3135
cron \
36+
sudo \
3237
libzip-dev \
38+
wget \
3339
librabbitmq-dev \
3440
&& pecl install amqp \
3541
&& docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \
@@ -46,11 +52,12 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \
4652
&& rm -rf /var/lib/apt/lists/* \
4753
&& apt-get clean
4854

49-
# create document root
50-
RUN mkdir -p $APP_HOME/public
51-
52-
# change owner
53-
RUN chown -R www-data:www-data $APP_HOME
55+
# create document root, fix permissions for www-data user and change owner to www-data
56+
RUN mkdir -p $APP_HOME/public && \
57+
mkdir -p /home/$USERNAME && chown $USERNAME:$USERNAME /home/$USERNAME \
58+
&& usermod -u $UID $USERNAME -d /home/$USERNAME \
59+
&& groupmod -g $GID $USERNAME \
60+
&& chown -R ${USERNAME}:${USERNAME} $APP_HOME
5461

5562
# put php config for Symfony
5663
COPY ./docker/$BUILD_ARGUMENT_ENV/www.conf /usr/local/etc/php-fpm.d/www.conf
@@ -61,6 +68,10 @@ COPY ./docker/general/do_we_need_xdebug.sh /tmp/
6168
COPY ./docker/dev/xdebug.ini /tmp/
6269
RUN chmod u+x /tmp/do_we_need_xdebug.sh && /tmp/do_we_need_xdebug.sh
6370

71+
# install security-checker in case dev/test environment
72+
COPY ./docker/general/do_we_need_security-checker.sh /tmp/
73+
RUN chmod u+x /tmp/do_we_need_security-checker.sh && /tmp/do_we_need_security-checker.sh
74+
6475
# install composer
6576
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
6677
RUN chmod +x /usr/bin/composer
@@ -69,19 +80,16 @@ ENV COMPOSER_ALLOW_SUPERUSER 1
6980
# add supervisor
7081
RUN mkdir -p /var/log/supervisor
7182
COPY --chown=root:root ./docker/general/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
72-
COPY --chown=root:root ./docker/general/cron /var/spool/cron/crontabs/root
83+
COPY --chown=root:crontab ./docker/general/cron /var/spool/cron/crontabs/root
7384
RUN chmod 0600 /var/spool/cron/crontabs/root
7485

7586
# set working directory
7687
WORKDIR $APP_HOME
7788

78-
# create composer folder for user www-data
79-
RUN mkdir -p /var/www/.composer && chown -R www-data:www-data /var/www/.composer
80-
81-
USER www-data
89+
USER ${USERNAME}
8290

8391
# copy source files
84-
COPY --chown=www-data:www-data . $APP_HOME/
92+
COPY --chown=${USERNAME}:${USERNAME} . $APP_HOME/
8593

8694
# install all PHP dependencies
8795
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-nginx:
7475
@docker-compose $(project) exec nginx /bin/sh
@@ -83,10 +84,13 @@ ssh-rabbitmq:
8384
@docker-compose $(project) exec rabbitmq /bin/sh
8485

8586
exec:
86-
@docker-compose $(project) exec $(optionT) symfony $$cmd
87+
@docker-compose $(project) exec $(optionT) $(symfony_user) symfony $$cmd
8788

8889
exec-bash:
89-
@docker-compose $(project) exec $(optionT) symfony bash -c "$(cmd)"
90+
@docker-compose $(project) exec $(optionT) $(symfony_user) symfony bash -c "$(cmd)"
91+
92+
exec-by-root:
93+
@docker-compose $(project) exec $(optionT) symfony $$cmd
9094

9195
report-prepare:
9296
mkdir -p $(dir)/reports/coverage
@@ -166,7 +170,7 @@ ecs-fix: ## Run The Easy Coding Standard to fix issues
166170

167171
###> phpmetrics ###
168172
phpmetrics:
169-
@make exec cmd="make phpmetrics-process"
173+
@make exec-by-root cmd="make phpmetrics-process"
170174

171175
phpmetrics-process: ## Generates PhpMetrics static analysis, should be run inside symfony container
172176
@mkdir -p reports/phpmetrics
@@ -176,7 +180,7 @@ phpmetrics-process: ## Generates PhpMetrics static analysis, should be run insid
176180
fi;
177181
@echo "\033[32mRunning PhpMetrics\033[39m"
178182
@php ./vendor/bin/phpmetrics --version
179-
@./vendor/bin/phpmetrics --junit=reports/junit.xml --report-html=reports/phpmetrics .
183+
@php ./vendor/bin/phpmetrics --junit=reports/junit.xml --report-html=reports/phpmetrics .
180184
###< phpmetrics ###
181185

182186
###> 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/asset": "4.4.*",
@@ -76,7 +76,6 @@
7676
"doctrine/doctrine-fixtures-bundle": "^3.4",
7777
"ergebnis/composer-normalize": "^2.13",
7878
"roave/security-advisories": "dev-master",
79-
"sensiolabs/security-checker": "^6.0",
8079
"symfony/debug-bundle": "4.4.*",
8180
"symfony/maker-bundle": "^1.26",
8281
"symfony/requirements-checker": "^2.0",
@@ -124,14 +123,14 @@
124123
"scripts": {
125124
"post-install-cmd": [
126125
"if test -d vendor/symfony/requirements-checker; then ./vendor/bin/requirements-checker; fi",
127-
"if test -d vendor/sensiolabs/security-checker; then ./vendor/bin/security-checker security:check; fi",
128126
"if test -d vendor/bamarni/composer-bin-plugin; then composer bin all install; fi",
127+
"if which local-php-security-checker; then local-php-security-checker --update-cache && local-php-security-checker; fi",
129128
"@auto-scripts"
130129
],
131130
"post-update-cmd": [
132131
"if test -d vendor/symfony/requirements-checker; then ./vendor/bin/requirements-checker; fi",
133-
"if test -d vendor/sensiolabs/security-checker; then ./vendor/bin/security-checker security:check; fi",
134132
"if test -d vendor/bamarni/composer-bin-plugin; then composer bin all update; fi",
133+
"if which local-php-security-checker; then local-php-security-checker --update-cache && local-php-security-checker; fi",
135134
"@auto-scripts"
136135
],
137136
"auto-scripts": {

0 commit comments

Comments
 (0)