[Maintenance][Docker]Create simple environment

This commit is contained in:
Ferror 2022-04-08 11:51:16 +02:00
parent 642142b434
commit 49589a8c83
6 changed files with 186 additions and 0 deletions

5
.docker/dev/php.ini Normal file
View file

@ -0,0 +1,5 @@
[PHP]
memory_limit=512M
[date]
date.timezone=${PHP_DATE_TIMEZONE}

15
.docker/test/php.ini Normal file
View file

@ -0,0 +1,15 @@
[PHP]
memory_limit=4096M
[date]
date.timezone=${PHP_DATE_TIMEZONE}
[opcache]
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=256
opcache.max_accelerated_files=32531
opcache.interned_strings_buffer=8
opcache.validate_timestamps=0
opcache.save_comments=1
opcache.fast_shutdown=0

55
.github/workflows/docker.yml vendored Normal file
View file

@ -0,0 +1,55 @@
name: Docker Based Pipeline
on:
push:
jobs:
docker-compose:
name: Excute Tests on Docker Compose
runs-on: ubuntu-latest
env:
COMPOSE_FILE: docker-compose.test.yml
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Run PHPUnit, PHPSpec and Behat tests
run: docker-compose run ci
docker:
name: Excute Tests on Docker Containers
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Shutdown default MySQL
run: sudo service mysql stop
-
name: Setup MySQL
run: |
docker network create sylius_network
docker run \
--platform linux/amd64 \
-e MYSQL_ALLOW_EMPTY_PASSWORD=true \
-p 3306:3306/tcp \
--name mysql \
--net sylius_network \
-d mysql:5.7
-
name: Run PHPUnit, PHPSpec and Behat tests
run: |
docker run \
-v "$(pwd)"/:/app:delegated \
-v "$(pwd)"/.docker/test/php.ini:/etc/php/8.0/fpm/php.ini:delegated \
-v "$(pwd)"/.docker/test/php.ini:/etc/php/8.0/cli/php.ini:delegated \
-e DATABASE_URL="mysql://root@mysql/sylius_test" \
-e APP_ENV="test" \
-e PHP_DATE_TIMEZONE="Europe/Warsaw" \
--net sylius_network \
--entrypoint="" \
-p 80:80/tcp \
-i sylius/standard:1.11-traditional \
make ci

28
Makefile Normal file
View file

@ -0,0 +1,28 @@
init:
composer install --no-interaction --no-scripts
bin/console sylius:install --no-interaction
bin/console sylius:fixtures:load default --no-interaction
yarn install --pure-lockfile
yarn build
ci:
composer install --no-interaction --no-scripts
bin/console sylius:install --no-interaction
bin/console sylius:fixtures:load default --no-interaction
bin/console cache:warmup
yarn install --pure-lockfile
yarn build
vendor/bin/phpunit
vendor/bin/phpspec run --ansi --no-interaction -f dot
vendor/bin/behat --colors --strict --no-interaction -vvv -f progress --tags="~@javascript&&@cli&&~@todo" # CLI Behat
vendor/bin/behat --colors --strict --no-interaction -vvv -f progress --tags="~@javascript&&~@cli&&~@todo" # NON JS Behat
#vendor/bin/behat --colors --strict --no-interaction -vvv -f progress --tags="@javascript&&~@cli&&~@todo" # JS Behat
unit:
vendor/bin/phpunit
spec:
vendor/bin/phpspec run --ansi --no-interaction -f dot
behat:
vendor/bin/behat --colors --strict --stop-on-failure --no-interaction -vvv -f progress

32
docker-compose.test.yml Normal file
View file

@ -0,0 +1,32 @@
services:
ci:
image: sylius/standard:1.11-traditional
entrypoint: ["make", "ci"]
environment:
APP_ENV: "test"
DATABASE_URL: "mysql://root:mysql@mysql/sylius_test"
PHP_DATE_TIMEZONE: "Europe/Warsaw"
volumes:
- ./:/app:delegated
- ./.docker/test/php.ini:/etc/php/8.0/fpm/php.ini:delegated
- ./.docker/test/php.ini:/etc/php/8.0/cli/php.ini:delegated
ports:
- 80:80
depends_on:
- mysql
networks:
- sylius
mysql:
image: mysql:5.7
platform: linux/amd64
environment:
- MYSQL_ROOT_PASSWORD=mysql
ports:
- 3306:3306
networks:
- sylius
networks:
sylius:
driver: bridge

51
docker-compose.yml Normal file
View file

@ -0,0 +1,51 @@
services:
app:
image: sylius/standard:1.11-traditional
environment:
APP_ENV: "dev"
DATABASE_URL: "mysql://root:mysql@mysql/sylius_%kernel.environment%"
# DATABASE_URL: "pgsql://root:postgres@postgres/sylius_%kernel.environment%" # When using postgres
PHP_DATE_TIMEZONE: "Europe/Warsaw"
MAILER_URL: "smtp://mailhog:1025"
volumes:
- ./:/app:delegated
- ./.docker/dev/php.ini:/etc/php/8.0/fpm/php.ini:delegated
- ./.docker/dev/php.ini:/etc/php/8.0/cli/php.ini:delegated
ports:
- 80:80
depends_on:
- mysql
networks:
- sylius
mysql:
image: mysql:5.7
platform: linux/amd64
environment:
- MYSQL_ROOT_PASSWORD=mysql
ports:
- 3306:3306
networks:
- sylius
# postgres:
# image: postgres:13
# environment:
# - POSTGRES_USER=root
# - POSTGRES_PASSWORD=postgres
# ports:
# - 5432:5432
# networks:
# - sylius
mailhog:
image: mailhog/mailhog
ports:
- 1025:1025 # SMTP
- 8025:8025 # UI
networks:
- sylius
networks:
sylius:
driver: bridge