Skip to content

Commit ce8ebe5

Browse files
author
dmitriy
committed
refactoring
1 parent a5f32ee commit ce8ebe5

12 files changed

+31
-37
lines changed

Dockerfile

+13-13
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ FROM php:7.3-apache
33
# set main params
44
ARG BUILD_ARGUMENT_DEBUG_ENABLED=false
55
ENV DEBUG_ENABLED=$BUILD_ARGUMENT_DEBUG_ENABLED
6-
ARG BUILD_ARGUMENT_APP_ENV=dev
7-
ENV APP_ENV=$BUILD_ARGUMENT_APP_ENV
6+
ARG BUILD_ARGUMENT_ENV=dev
7+
ENV ENV=$BUILD_ARGUMENT_ENV
88
ENV APP_HOME /var/www/html
99

1010
# check environment
11-
RUN if [ "$BUILD_ARGUMENT_APP_ENV" = "default" ]; then echo "Set BUILD_ARGUMENT_APP_ENV in docker build-args like --build-arg BUILD_ARGUMENT_APP_ENV=dev" && exit 2; \
12-
elif [ "$BUILD_ARGUMENT_APP_ENV" = "dev" ]; then echo "Building development environment."; \
13-
elif [ "$BUILD_ARGUMENT_APP_ENV" = "test" ]; then echo "Building test environment."; \
14-
elif [ "$BUILD_ARGUMENT_APP_ENV" = "prod" ]; then echo "Building production environment."; \
15-
else echo "Set correct BUILD_ARGUMENT_APP_ENV in docker build-args like --build-arg BUILD_ARGUMENT_APP_ENV=dev. Available choices are dev,test,prod." && exit 2; \
11+
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; \
12+
elif [ "$BUILD_ARGUMENT_ENV" = "dev" ]; then echo "Building development environment."; \
13+
elif [ "$BUILD_ARGUMENT_ENV" = "test" ]; then echo "Building test environment."; \
14+
elif [ "$BUILD_ARGUMENT_ENV" = "prod" ]; then echo "Building production environment."; \
15+
else echo "Set correct BUILD_ARGUMENT_ENV in docker build-args like --build-arg BUILD_ARGUMENT_ENV=dev. Available choices are dev,test,prod." && exit 2; \
1616
fi
1717

1818
# install all the dependencies and enable PHP modules
@@ -55,7 +55,7 @@ RUN chown -R www-data:www-data $APP_HOME
5555
COPY ./docker/hosts/symfony.conf /etc/apache2/sites-available/symfony.conf
5656
COPY ./docker/hosts/symfony-ssl.conf /etc/apache2/sites-available/symfony-ssl.conf
5757
RUN a2ensite symfony.conf && a2ensite symfony-ssl
58-
COPY ./docker/$BUILD_ARGUMENT_APP_ENV/php.ini /usr/local/etc/php/php.ini
58+
COPY ./docker/$BUILD_ARGUMENT_ENV/php.ini /usr/local/etc/php/php.ini
5959

6060
# enable apache modules
6161
RUN a2enmod rewrite
@@ -64,15 +64,15 @@ RUN a2enmod ssl
6464
# install Xdebug in case development or test environment
6565
COPY ./docker/other/do_we_need_xdebug.sh /tmp/
6666
COPY ./docker/dev/xdebug.ini /tmp/
67-
RUN chmod u+x /tmp/do_we_need_xdebug.sh && /tmp/do_we_need_xdebug.sh $BUILD_ARGUMENT_APP_ENV
67+
RUN chmod u+x /tmp/do_we_need_xdebug.sh && /tmp/do_we_need_xdebug.sh
6868

6969
# install composer
7070
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
7171

7272
# add supervisor
7373
RUN mkdir -p /var/log/supervisor
7474
COPY --chown=root:root ./docker/other/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
75-
COPY --chown=root:root ./docker/$BUILD_ARGUMENT_APP_ENV/cron /var/spool/cron/crontabs/root
75+
COPY --chown=root:root ./docker/other/cron /var/spool/cron/crontabs/root
7676
RUN chmod 0600 /var/spool/cron/crontabs/root
7777

7878
# generate certificates
@@ -91,12 +91,12 @@ USER www-data
9191
COPY --chown=www-data:www-data . $APP_HOME/
9292

9393
# install all PHP dependencies
94-
RUN if [ "$BUILD_ARGUMENT_APP_ENV" = "dev" ] || [ "$BUILD_ARGUMENT_APP_ENV" = "test" ]; then composer install --optimize-autoloader --no-interaction --no-progress; \
95-
else composer install --optimize-autoloader --no-interaction --no-progress --no-dev; \
94+
RUN if [ "$BUILD_ARGUMENT_ENV" = "dev" ] || [ "$BUILD_ARGUMENT_ENV" = "test" ]; then composer install --optimize-autoloader --no-interaction --no-progress; \
95+
else export APP_ENV=$BUILD_ARGUMENT_ENV && composer install --optimize-autoloader --no-interaction --no-progress --no-dev; \
9696
fi
9797

9898
# create cached config file .env.local.php in case prod environment
99-
RUN if [ "$BUILD_ARGUMENT_APP_ENV" = "prod" ]; then composer dump-env $BUILD_ARGUMENT_APP_ENV; \
99+
RUN if [ "$BUILD_ARGUMENT_ENV" = "prod" ]; then composer dump-env $BUILD_ARGUMENT_ENV; \
100100
fi
101101

102102
USER root

Makefile

+3-6
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,19 @@ info:
5959
@make exec cmd="php --version"
6060

6161
drop-migrate:
62-
@make exec cmd="php bin/console doctrine:schema:drop --full-database --force --env=dev"
62+
@make exec cmd="php bin/console doctrine:schema:drop --full-database --force"
6363
@make exec cmd="php bin/console doctrine:schema:drop --full-database --force --env=test"
6464
@make migrate
6565

6666
migrate-prod:
6767
@make exec cmd="php bin/console doctrine:migrations:migrate --no-interaction"
6868

6969
migrate:
70-
@make exec cmd="php bin/console doctrine:migrations:migrate --no-interaction --env=dev"
70+
@make exec cmd="php bin/console doctrine:migrations:migrate --no-interaction"
7171
@make exec cmd="php bin/console doctrine:migrations:migrate --no-interaction --env=test"
7272

73-
fixtures-prod:
74-
@make exec cmd="php bin/console doctrine:fixtures:load --append"
75-
7673
fixtures:
77-
@make exec cmd="php bin/console doctrine:fixtures:load --append --env=dev"
74+
@make exec cmd="php bin/console doctrine:fixtures:load --append"
7875

7976
phpunit:
8077
@make exec cmd="./vendor/bin/simple-phpunit -c phpunit.xml.dist --log-junit reports/phpunit.xml --coverage-html reports/coverage --coverage-clover reports/coverage.xml"

composer.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-compose-prod.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
build:
88
context: .
99
args:
10-
- "BUILD_ARGUMENT_APP_ENV=prod"
10+
- "BUILD_ARGUMENT_ENV=prod"
1111
- "BUILD_ARGUMENT_DEBUG_ENABLED=false"
1212
dockerfile: ./Dockerfile
1313
container_name: symfony
@@ -27,7 +27,7 @@ services:
2727
build:
2828
context: .
2929
args:
30-
- "BUILD_ARGUMENT_APP_ENV=prod"
30+
- "BUILD_ARGUMENT_ENV=prod"
3131
- "BUILD_ARGUMENT_DEBUG_ENABLED=false"
3232
dockerfile: ./Dockerfile
3333
container_name: supervisord

docker-compose-test-ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
build:
88
context: .
99
args:
10-
- "BUILD_ARGUMENT_APP_ENV=test"
10+
- "BUILD_ARGUMENT_ENV=test"
1111
- "BUILD_ARGUMENT_DEBUG_ENABLED=false"
1212
dockerfile: ./Dockerfile
1313
container_name: symfony
@@ -27,7 +27,7 @@ services:
2727
build:
2828
context: .
2929
args:
30-
- "BUILD_ARGUMENT_APP_ENV=test"
30+
- "BUILD_ARGUMENT_ENV=test"
3131
- "BUILD_ARGUMENT_DEBUG_ENABLED=false"
3232
dockerfile: ./Dockerfile
3333
container_name: supervisord

docker-compose.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
build:
88
context: .
99
args:
10-
- "BUILD_ARGUMENT_APP_ENV=dev"
10+
- "BUILD_ARGUMENT_ENV=dev"
1111
- "BUILD_ARGUMENT_DEBUG_ENABLED=false"
1212
dockerfile: ./Dockerfile
1313
container_name: symfony
@@ -29,7 +29,7 @@ services:
2929
build:
3030
context: .
3131
args:
32-
- "BUILD_ARGUMENT_APP_ENV=dev"
32+
- "BUILD_ARGUMENT_ENV=dev"
3333
- "BUILD_ARGUMENT_DEBUG_ENABLED=false"
3434
dockerfile: ./Dockerfile
3535
container_name: supervisord

docker/dev/cron docker/other/cron

File renamed without changes.

docker/other/do_we_need_xdebug.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash -x
22

3-
if [ "$APP_ENV" == "dev" ] || [ "$APP_ENV" == "test" ]; then
3+
if [ "$ENV" == "dev" ] || [ "$ENV" == "test" ]; then
44
#pecl install xdebug - enable it when Xdebug 2.7.0 will be released
55
pecl install xdebug-beta
66
mv /tmp/xdebug.ini /usr/local/etc/php/conf.d/

docker/prod/cron

-1
This file was deleted.

docker/test/cron

-1
This file was deleted.

phpunit.xml.dist

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer">
1212
<php>
1313
<ini name="error_reporting" value="-1" />
14-
<server name="APP_ENV" value="test" />
1514
<env name="APP_ENV" value="test" />
1615
<env name="SYMFONY_PHPUNIT_VERSION" value="7" />
1716
<env name="SHELL_VERBOSITY" value="-1" />

symfony.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@
299299
"repo": "github.com/symfony/recipes",
300300
"branch": "master",
301301
"version": "4.2",
302-
"ref": "5bb3a8c27df824d195fa68bb635d074854f8498f"
302+
"ref": "9aafbc8edf7558dfe213e9d51d0217cbd78acc5a"
303303
},
304304
"files": [
305305
"config/bootstrap.php",
@@ -357,7 +357,7 @@
357357
"version": "v1.0.6"
358358
},
359359
"symfony/panther": {
360-
"version": "v0.2.0"
360+
"version": "v0.3.0"
361361
},
362362
"symfony/phpunit-bridge": {
363363
"version": "4.1",

0 commit comments

Comments
 (0)