Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OP-291: Refactor plugin configuration #266

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .docker/fpm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[www]
user = www-data
group = www-data

listen = /var/run/php-www.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660

clear_env = no

pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

pm.status_path = /status
catch_workers_output = yes

security.limit_extensions = .php
48 changes: 48 additions & 0 deletions .docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
user www-data;
worker_processes auto;
daemon off;
pid /run/nginx.pid;

include /etc/nginx/modules-enabled/*.conf;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

server_tokens off;

client_max_body_size 64m;
sendfile on;
tcp_nodelay on;
tcp_nopush on;

gzip_vary on;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

server {
listen 80;

root /app/tests/Application/public;
index index.php;

location / {
try_files $uri /index.php$is_args$args;
}

location ~ \.php$ {
include fastcgi_params;

fastcgi_pass unix:/var/run/php-www.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;

fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
}
}
15 changes: 15 additions & 0 deletions .docker/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[PHP]
memory_limit=512M

[date]
date.timezone=${PHP_DATE_TIMEZONE}

[opcache]
opcache.enable=0
opcache.memory_consumption=256
opcache.max_accelerated_files=20000
opcache.validate_timestamps=0
;opcache.preload=/app/config/preload.php
opcache.preload_user=www-data
opcache.jit=1255
opcache.jit_buffer_size=256M
14 changes: 14 additions & 0 deletions .docker/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[supervisord]
nodaemon = true
user = root
pidfile = /run/supervisord.pid

[program:nginx]
command = /usr/sbin/nginx
user = root
autostart = true

[program:php-fpm]
command = /usr/sbin/php-fpm -F
user = root
autostart = true
5 changes: 0 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ jobs:
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}-yarn-

-
name: Copy package.json.dist to package.json
if: matrix.sylius != ''
run: (cd tests/Application && cp package.json.\${{ matrix.sylius }}.dist package.json)

-
name: Install JS dependencies
run: (cd tests/Application && yarn install)
Expand Down
73 changes: 73 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
ARG PHP_VERSION=8.1
ENV LC_ALL=C.UTF-8

# Install basic tools
RUN apt-get update && apt-get install -y \
software-properties-common \
curl \
make \
supervisor \
unzip \
python2 \
g++

# Append NODE, NGINX and PHP repositories
RUN add-apt-repository ppa:ondrej/php \
&& add-apt-repository ppa:ondrej/nginx \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash -

# Install required PHP extensions
RUN apt-get update && apt-get install -y \
nodejs \
nginx \
php${PHP_VERSION} \
php${PHP_VERSION}-apcu \
php${PHP_VERSION}-calendar \
php${PHP_VERSION}-common \
php${PHP_VERSION}-cli \
php${PHP_VERSION}-ctype \
php${PHP_VERSION}-curl \
php${PHP_VERSION}-dom \
php${PHP_VERSION}-exif \
php${PHP_VERSION}-fpm \
php${PHP_VERSION}-gd \
php${PHP_VERSION}-intl \
php${PHP_VERSION}-mbstring \
php${PHP_VERSION}-mysql \
php${PHP_VERSION}-opcache \
php${PHP_VERSION}-pdo \
php${PHP_VERSION}-pgsql \
php${PHP_VERSION}-sqlite \
php${PHP_VERSION}-xml \
php${PHP_VERSION}-xsl \
php${PHP_VERSION}-yaml \
php${PHP_VERSION}-zip

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

# Cleanup
RUN apt-get remove --purge -y software-properties-common curl && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* /usr/share/man/*

# Create directory for php-fpm socket
# Link php-fpm binary file without version
# -p Creates missing intermediate path name directories
RUN ln -s /usr/sbin/php-fpm${PHP_VERSION} /usr/sbin/php-fpm && mkdir -p /run/php

# Install yarn
RUN npm install -g yarn && npm cache clean --force

# Initialize config files
COPY .docker/supervisord.conf /etc/supervisor/conf.d/supervisor.conf
COPY .docker/nginx.conf /etc/nginx/nginx.conf
COPY .docker/fpm.conf /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf
COPY .docker/php.ini /etc/php/${PHP_VERSION}/fpm/php.ini
COPY .docker/php.ini /etc/php/${PHP_VERSION}/cli/php.ini

WORKDIR /app

EXPOSE 80

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
18 changes: 14 additions & 4 deletions doc/01-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,23 @@ bitbag_sylius_wishlist_plugin:
resource: "@BitBagSyliusWishlistPlugin/Resources/config/routing.yml"
```

5. Clear application cache by using command:
5. Override `OrderItemController`
```yaml
sylius_order:
resources:
order_item:
classes:
controller: BitBag\SyliusWishlistPlugin\Controller\OrderItemController

```

6. Clear application cache by using command:

```bash
$ bin/console cache:clear
```

6. Update your database
7. Update your database

First, please run legacy-versioned migrations by using command:

Expand All @@ -71,14 +81,14 @@ $ bin/console doctrine:migrations:migrate
$ bin/console doctrine:migrations:version BitBag\\SyliusWishlistPlugin\\Migrations\\Version20201029161558 --add --no-interaction
```

7. Please add plugin templates into your project:
8. Please add plugin templates into your project:
```bash
$ cp -R vendor/bitbag/wishlist-plugin/tests/Application/templates/bundles/SyliusShopBundle/Product templates/bundles/SyliusShopBundle
$ cp vendor/bitbag/wishlist-plugin/tests/Application/templates/bundles/SyliusShopBundle/_header.html.twig templates/bundles/SyliusShopBundle
$ cp vendor/bitbag/wishlist-plugin/tests/Application/templates/bundles/SyliusShopBundle/_logo.html.twig templates/bundles/SyliusShopBundle
```

8. Add plugin assets to your project
9. Add plugin assets to your project

We recommend you to use Webpack (Encore), for which we have prepared four different instructions on how to add this plugin's assets to your project:

Expand Down
45 changes: 45 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
services:
app:
container_name: app
build:
context: .
environment:
APP_ENV: "dev"
DATABASE_URL: "mysql://root:mysql@mysql/sylius_%kernel.environment%?charset=utf8mb4"
# DATABASE_URL: "pgsql://root:postgres@postgres/sylius_%kernel.environment%?charset=utf8" # When using postgres
PHP_DATE_TIMEZONE: "Europe/Warsaw"
volumes:
- ./:/app:delegated
- ./.docker/php.ini:/etc/php8/php.ini:delegated
- ./.docker/nginx.conf:/etc/nginx/nginx.conf:delegated
ports:
- 80:80
depends_on:
- mysql
networks:
- sylius

mysql:
container_name: mysql
image: mysql:8.0
platform: linux/amd64
environment:
MYSQL_ROOT_PASSWORD: mysql
ports:
- ${MYSQL_PORT:-3306}:3306
networks:
- sylius

# postgres:
# image: postgres:14-alpine
# environment:
# POSTGRES_USER: root
# POSTGRES_PASSWORD: postgres
# ports:
# - ${POSTGRES_PORT:-5432}:5432
# networks:
# - sylius

networks:
sylius:
driver: bridge
1 change: 0 additions & 1 deletion src/Resources/config/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
imports:
- { resource: "@BitBagSyliusWishlistPlugin/Resources/config/services.xml" }
- { resource: "@BitBagSyliusWishlistPlugin/Resources/config/resources.yml" }
5 changes: 0 additions & 5 deletions src/Resources/config/resources.yml

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Application/.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ APP_SECRET=EDITME
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls
DATABASE_URL=mysql://root@127.0.0.1/sylius_wish_list_plugin_%kernel.environment%?serverVersion=5.7
DATABASE_URL=mysql://root@127.0.0.1/sylius_wish_list_plugin_%kernel.environment%
###< doctrine/doctrine-bundle ###

###> symfony/swiftmailer-bundle ###
Expand Down
5 changes: 5 additions & 0 deletions tests/Application/config/resources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sylius_order:
resources:
order_item:
classes:
controller: BitBag\SyliusWishlistPlugin\Controller\OrderItemController
41 changes: 0 additions & 41 deletions tests/Application/package.json.~1.13.0.dist

This file was deleted.

Loading