Skip to content

Commit

Permalink
Merge pull request #5487 from chihiro-adachi/merge-41
Browse files Browse the repository at this point in the history
4.1ブランチの修正を4.2ブランチへマージ
  • Loading branch information
taguchimasahiro authored Aug 2, 2022
2 parents c0d4018 + d66ba86 commit 8545d89
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 91 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/deny-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,17 @@ jobs:
run: ${{ github.event.repository.name }}/package.sh

- name: Build Container
run: docker build -t ec-cube --build-arg SKIP_INSTALL_SCRIPT_ON_DOCKER_BUILD=true .
run: docker build -t ec-cube .

- name: Container Run
run: |
docker run -e APP_ENV=prod -e APP_DEBUG=0 -e DATABASE_URL="sqlite:///var/eccube.db" -e DATABASE_SERVER_VERSION=3 --rm -d -p 8080:80 --name eccube ec-cube
echo -n $(docker inspect -f {{.State.Health.Status}} eccube)
until [ $(docker inspect -f {{.State.Health.Status}} eccube) != "starting" ]; do
echo -n .
sleep 10;
done;
docker inspect -f {{.State.Health.Status}} eccube
docker cp ../eccube.tar.gz eccube:/tmp/
docker exec -w /tmp eccube bash -c "rm -rf /var/www/html; tar xf /tmp/eccube.tar.gz -C /var/www; mv /var/www/ec-cube /var/www/html; chown -R www-data: /var/www/html"
docker exec -u www-data eccube bin/console eccube:install -n
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/dockerbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
uses: actions/checkout@master

- name: docker build
run: docker-compose build
run: docker compose build

- name: Get Composer Cache Directory
id: composer-cache
Expand All @@ -70,11 +70,9 @@ jobs:
DATABASE_URL: ${{ matrix.database_url }}
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
run: |
docker-compose -f docker-compose.yml -f docker-compose.pgsql.yml up -d
docker-compose -f docker-compose.yml -f docker-compose.pgsql.yml exec -T ec-cube bin/console doctrine:schema:create --env=dev
docker-compose -f docker-compose.yml -f docker-compose.pgsql.yml exec -T ec-cube bin/console eccube:fixtures:load --env=dev
docker compose -f docker-compose.yml -f docker-compose.pgsql.yml up -d --wait
sed -i 's!APP_ENV: "dev"!APP_ENV: "prod"!g' docker-compose.yml
docker-compose -f docker-compose.yml -f docker-compose.pgsql.yml up -d
docker compose -f docker-compose.yml -f docker-compose.pgsql.yml up -d --wait
- name: setup-chromedriver
uses: nanasess/setup-chromedriver@master
Expand Down
40 changes: 1 addition & 39 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,35 +61,12 @@ RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY dockerbuild/php.ini $PHP_INI_DIR/conf.d/
COPY dockerbuild/docker-php-entrypoint /usr/local/bin/

RUN chown www-data:www-data /var/www \
&& mkdir -p ${APACHE_DOCUMENT_ROOT}/vendor \
&& mkdir -p ${APACHE_DOCUMENT_ROOT}/var \
&& chown www-data:www-data ${APACHE_DOCUMENT_ROOT}/vendor \
&& chmod g+s ${APACHE_DOCUMENT_ROOT}/vendor \
&& chown www-data:www-data ${APACHE_DOCUMENT_ROOT}/var

RUN curl -sS https://getcomposer.org/installer \
| php \
&& mv composer.phar /usr/bin/composer

# 全体コピー前にcomposer installを先行完了させる(docker cache利用によるリビルド速度向上)

RUN composer config -g repos.packagist composer https://packagist.jp
COPY composer.json ${APACHE_DOCUMENT_ROOT}/composer.json
COPY composer.lock ${APACHE_DOCUMENT_ROOT}/composer.lock
RUN chown www-data:www-data ${APACHE_DOCUMENT_ROOT}/composer.*

USER www-data
RUN composer install \
--no-scripts \
--no-autoloader \
--no-plugins \
-d ${APACHE_DOCUMENT_ROOT} \
;

##################################################################
# ファイル変更時、以後のステップにはキャッシュが効かなくなる
USER root
COPY . ${APACHE_DOCUMENT_ROOT}
WORKDIR ${APACHE_DOCUMENT_ROOT}

Expand All @@ -99,19 +76,4 @@ RUN find ${APACHE_DOCUMENT_ROOT} \( -path ${APACHE_DOCUMENT_ROOT}/vendor -prune
| xargs -0 chmod g+s \
;

USER www-data
RUN composer dumpautoload -o --apcu

RUN if [ ! -f ${APACHE_DOCUMENT_ROOT}/.env ]; then \
cp -p .env.dist .env \
; fi

# trueを指定した場合、DBマイグレーションやECCubeのキャッシュ作成をスキップする。
# ビルド時点でDBを起動出来ない場合等に指定が必要となる。
ARG SKIP_INSTALL_SCRIPT_ON_DOCKER_BUILD=false

RUN if [ ! -f ${APACHE_DOCUMENT_ROOT}/var/eccube.db ] && [ ! ${SKIP_INSTALL_SCRIPT_ON_DOCKER_BUILD} = "true" ]; then \
composer run-script installer-scripts && composer run-script auto-scripts \
; fi

USER root
HEALTHCHECK --interval=10s --timeout=5s --retries=30 CMD pgrep apache
10 changes: 8 additions & 2 deletions docker-compose.mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ volumes:
services:
ec-cube:
depends_on:
- mysql
mysql:
condition: service_healthy
environment:
DATABASE_URL: "mysql://dbuser:secret@mysql/eccubedb"
DATABASE_SERVER_VERSION: 5.7
Expand All @@ -17,12 +18,17 @@ services:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: eccubedb
MYSQL_USER: dbuser
MYSQL_PASSWORD: secret
volumes:
- mysql-database:/var/lib/mysql
- ./dockerbuild/grant_to_dbuser.sql:/docker-entrypoint-initdb.d/grant_to_dbuser.sql
ports:
- 13306:3306
networks:
- backend
healthcheck:
test: mysqladmin ping
interval: 3s
timeout: 3s
retries: 3
9 changes: 7 additions & 2 deletions docker-compose.pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ volumes:
services:
ec-cube:
depends_on:
- postgres
postgres:
condition: service_healthy
environment:
DATABASE_URL: "postgres://dbuser:secret@postgres/eccubedb"
DATABASE_SERVER_VERSION: 14
Expand All @@ -16,7 +17,6 @@ services:
postgres:
image: postgres:14
environment:
POSTGRES_DB: eccubedb
POSTGRES_USER: dbuser
POSTGRES_PASSWORD: secret
ports:
Expand All @@ -25,3 +25,8 @@ services:
- pg-database:/var/lib/postgresql/data
networks:
- backend
healthcheck:
test: pg_isready -U dbuser
interval: 3s
timeout: 3s
retries: 3
4 changes: 0 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ services:
ec-cube:
build:
context: .
args:
# ビルド時のECCubeインストールスクリプトをスキップする場合にtrueを指定する。
# ビルド時点でDBサーバの起動や接続が出来ない、という場合等にエラーとなるため。
SKIP_INSTALL_SCRIPT_ON_DOCKER_BUILD: "true"
ports:
- 8080:80
- 4430:443
Expand Down
22 changes: 22 additions & 0 deletions dockerbuild/docker-php-entrypoint
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
#!/bin/sh
set -e

if [ ! -d /var/www/html/vendor/bin ]; then
composer install \
--no-scripts \
--no-autoloader \
--no-plugins \
-d ${APACHE_DOCUMENT_ROOT}
composer dumpautoload -o --apcu
chown -R www-data: vendor
fi

bin/console doctrine:query:sql 'select * from dtb_base_info' > /dev/null 2>&1 || (
if [ -z ${DATABASE_URL} ]; then
cp .env.dist .env
fi
composer run-script installer-scripts
composer run-script auto-scripts
find ${APACHE_DOCUMENT_ROOT} \( -path ${APACHE_DOCUMENT_ROOT}/vendor -prune \) -or -print0 \
| xargs -0 chown www-data:www-data
find ${APACHE_DOCUMENT_ROOT} \( -path ${APACHE_DOCUMENT_ROOT}/vendor -prune \) -or \( -type d -print0 \) \
| xargs -0 chmod g+s
)

echo "PassEnv APP_ENV APP_DEBUG TRUSTED_PROXIES TRUSTED_HOSTS" > /etc/apache2/conf-enabled/eccube_env.conf

# first arg is `-f` or `--some-option`
Expand Down
1 change: 1 addition & 0 deletions dockerbuild/grant_to_dbuser.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GRANT ALL PRIVILEGES ON *.* TO 'dbuser'@'%';
20 changes: 12 additions & 8 deletions src/Eccube/Controller/Admin/Product/CsvImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1132,10 +1132,12 @@ protected function createProductClass($row, Product $Product, $data, $headerByKe
}
}

if (isset($row[$headerByKey['product_code']]) && StringUtil::isNotBlank($row[$headerByKey['product_code']])) {
$ProductClass->setCode(StringUtil::trimAll($row[$headerByKey['product_code']]));
} else {
$ProductClass->setCode(null);
if (isset($row[$headerByKey['product_code']])) {
if (StringUtil::isNotBlank($row[$headerByKey['product_code']])) {
$ProductClass->setCode(StringUtil::trimAll($row[$headerByKey['product_code']]));
} else {
$ProductClass->setCode(null);
}
}

if (!isset($row[$headerByKey['stock_unlimited']])
Expand Down Expand Up @@ -1310,10 +1312,12 @@ protected function updateProductClass($row, Product $Product, ProductClass $Prod
}
}

if (isset($row[$headerByKey['product_code']]) && StringUtil::isNotBlank($row[$headerByKey['product_code']])) {
$ProductClass->setCode(StringUtil::trimAll($row[$headerByKey['product_code']]));
} else {
$ProductClass->setCode(null);
if (isset($row[$headerByKey['product_code']])) {
if (StringUtil::isNotBlank($row[$headerByKey['product_code']])) {
$ProductClass->setCode(StringUtil::trimAll($row[$headerByKey['product_code']]));
} else {
$ProductClass->setCode(null);
}
}

if (!isset($row[$headerByKey['stock_unlimited']])
Expand Down
12 changes: 4 additions & 8 deletions src/Eccube/Form/Type/PhoneNumberType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;

Expand Down Expand Up @@ -56,29 +55,26 @@ public function buildForm(FormBuilderInterface $builder, array $options)
*/
public function configureOptions(OptionsResolver $resolver)
{
$eccubeConfig = $this->eccubeConfig;
$constraints = function (Options $options) use ($eccubeConfig) {
$resolver->setNormalizer('constraints', function($options, $value) {
$constraints = [];
// requiredがtrueに指定されている場合, NotBlankを追加
if (isset($options['required']) && true === $options['required']) {
$constraints[] = new Assert\NotBlank();
}

$constraints[] = new Assert\Length([
'max' => $eccubeConfig['eccube_tel_len_max'],
'max' => $this->eccubeConfig['eccube_tel_len_max'],
]);

$constraints[] = new Assert\Type([
'type' => 'digit',
'message' => 'form_error.numeric_only',
]);

return $constraints;
};
return array_merge($constraints, $value);
});

$resolver->setDefaults([
'options' => ['constraints' => []],
'constraints' => $constraints,
'attr' => [
'placeholder' => 'common.phone_number_sample',
],
Expand Down
11 changes: 4 additions & 7 deletions src/Eccube/Form/Type/PostalType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;

Expand Down Expand Up @@ -55,29 +54,27 @@ public function buildForm(FormBuilderInterface $builder, array $options)
*/
public function configureOptions(OptionsResolver $resolver)
{
$eccubeConfig = $this->eccubeConfig;
$constraints = function (Options $options) use ($eccubeConfig) {
$resolver->setNormalizer('constraints', function($options, $value) {
$constraints = [];
// requiredがtrueに指定されている場合, NotBlankを追加
if (isset($options['required']) && true === $options['required']) {
$constraints[] = new Assert\NotBlank();
}

$constraints[] = new Assert\Length([
'max' => $eccubeConfig['eccube_postal_code'],
'max' => $this->eccubeConfig['eccube_postal_code'],
]);

$constraints[] = new Assert\Type([
'type' => 'digit',
'message' => 'form_error.numeric_only',
]);

return $constraints;
};
return array_merge($constraints, $value);
});

$resolver->setDefaults([
'options' => [],
'constraints' => $constraints,
'attr' => [
'class' => 'p-postal-code',
'placeholder' => 'common.postal_code_sample',
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Resource/locale/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ front.shopping.confirm_title: Review Your Order
front.shopping.checkout: Place an Order
front.shopping.back_to_order: Go back to Checkout
front.shopping.complete_title: Order Placed
front.shopping.complete_message__title: Thank you for your oder!
front.shopping.complete_message__title: Thank you for your order!
front.shopping.complete_message__body: |
We have sent an order confirmation email.
In case you do not receive it, please contact us as your order may have not been received.
Expand Down
1 change: 0 additions & 1 deletion src/Eccube/Resource/template/admin/Order/edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ file that was distributed with this source code.
</div>
<form name="form1" id="form1" method="post" action="?"{% if BaseInfo.isOptionPoint and Order.Customer is not null %} onsubmit="updatePointItem()"{% endif %}>
<input type="hidden" name="mode" value="">
<input type="hidden" name="modal" value="">
{{ form_widget(form._token) }}
{{ form_widget(form.return_link) }}
<div class="c-contentsArea__cols">
Expand Down
Loading

0 comments on commit 8545d89

Please sign in to comment.