Skip to content

Commit c0e7e8e

Browse files
author
DKravtsov
committed
refactoring environment
1 parent 2114a48 commit c0e7e8e

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

+1786
-2097
lines changed

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
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

Dockerfile

Lines changed: 15 additions & 11 deletions
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,12 +33,14 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \
2933
libreadline-dev \
3034
supervisor \
3135
cron \
36+
sudo \
3237
libzip-dev \
3338
wget \
3439
librabbitmq-dev \
3540
&& pecl install amqp \
3641
&& docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \
3742
&& docker-php-ext-configure intl \
43+
&& yes '' | pecl install -o -f redis && docker-php-ext-enable redis \
3844
&& docker-php-ext-install \
3945
pdo_mysql \
4046
sockets \
@@ -47,11 +53,12 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \
4753
&& rm -rf /var/lib/apt/lists/* \
4854
&& apt-get clean
4955

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

5663
# put php config for Symfony
5764
COPY ./docker/$BUILD_ARGUMENT_ENV/www.conf /usr/local/etc/php-fpm.d/www.conf
@@ -74,19 +81,16 @@ ENV COMPOSER_ALLOW_SUPERUSER 1
7481
# add supervisor
7582
RUN mkdir -p /var/log/supervisor
7683
COPY --chown=root:root ./docker/general/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
77-
COPY --chown=root:root ./docker/general/cron /var/spool/cron/crontabs/root
84+
COPY --chown=root:crontab ./docker/general/cron /var/spool/cron/crontabs/root
7885
RUN chmod 0600 /var/spool/cron/crontabs/root
7986

8087
# set working directory
8188
WORKDIR $APP_HOME
8289

83-
# create composer folder for user www-data
84-
RUN mkdir -p /var/www/.composer && chown -R www-data:www-data /var/www/.composer
85-
86-
USER www-data
90+
USER ${USERNAME}
8791

8892
# copy source files
89-
COPY --chown=www-data:www-data . $APP_HOME/
93+
COPY --chown=${USERNAME}:${USERNAME} . $APP_HOME/
9094

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

Makefile

Lines changed: 9 additions & 5 deletions
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)
@@ -87,7 +88,7 @@ endif
8788
###< lexik/jwt-authentication-bundle ###
8889

8990
ssh:
90-
@docker-compose $(project) exec $(optionT) symfony bash
91+
@docker-compose $(project) exec $(optionT) $(symfony_user) symfony bash
9192

9293
ssh-nginx:
9394
@docker-compose $(project) exec nginx /bin/sh
@@ -108,10 +109,13 @@ ssh-kibana:
108109
@docker-compose $(project) exec kibana bash
109110

110111
exec:
111-
@docker-compose $(project) exec $(optionT) symfony $$cmd
112+
@docker-compose $(project) exec $(optionT) $(symfony_user) symfony $$cmd
112113

113114
exec-bash:
114-
@docker-compose $(project) exec $(optionT) symfony bash -c "$(cmd)"
115+
@docker-compose $(project) exec $(optionT) $(symfony_user) symfony bash -c "$(cmd)"
116+
117+
exec-by-root:
118+
@docker-compose $(project) exec $(optionT) symfony $$cmd
115119

116120
report-prepare:
117121
mkdir -p $(dir)/reports/coverage
@@ -209,7 +213,7 @@ ecs-fix: ## Run The Easy Coding Standard to fix issues
209213

210214
###> phpmetrics ###
211215
phpmetrics:
212-
@make exec cmd="make phpmetrics-process"
216+
@make exec-by-root cmd="make phpmetrics-process"
213217

214218
phpmetrics-process: ## Generates PhpMetrics static analysis, should be run inside symfony container
215219
@mkdir -p reports/phpmetrics
@@ -219,7 +223,7 @@ phpmetrics-process: ## Generates PhpMetrics static analysis, should be run insid
219223
fi;
220224
@echo "\033[32mRunning PhpMetrics\033[39m"
221225
@php ./vendor/bin/phpmetrics --version
222-
@./vendor/bin/phpmetrics --junit=reports/junit.xml --report-html=reports/phpmetrics .
226+
@php ./vendor/bin/phpmetrics --junit=reports/junit.xml --report-html=reports/phpmetrics .
223227
###< phpmetrics ###
224228

225229
###> php copy/paste detector ###

composer.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,6 @@
7171
"symfony/web-link": "4.4.*",
7272
"symfony/yaml": "4.4.*"
7373
},
74-
"replace": {
75-
"paragonie/random_compat": "2.*",
76-
"symfony/polyfill-ctype": "*",
77-
"symfony/polyfill-iconv": "*",
78-
"symfony/polyfill-php56": "*",
79-
"symfony/polyfill-php70": "*",
80-
"symfony/polyfill-php71": "*",
81-
"symfony/polyfill-php72": "*"
82-
},
8374
"conflict": {
8475
"symfony/symfony": "*"
8576
},

0 commit comments

Comments
 (0)