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

Single Container #70

Draft
wants to merge 18 commits into
base: develop
Choose a base branch
from
Draft

Single Container #70

wants to merge 18 commits into from

Conversation

adriendupuis
Copy link
Owner

@adriendupuis adriendupuis commented Mar 17, 2022

Run Ibexa DXP 4.1, 4.0, 3.3 or eZ Platform 2.5 in a single container with less installation as possible.

TODO:

  • Maybe mount some volume to access project from outside
  • Pass credentials as ARG instead of COPY auth.json
  • Adjust DATABASE_VERSION in, at least, .env

@adriendupuis adriendupuis changed the title Simple Single Container Single Container Apr 1, 2022
RUN npm install -g yarn

#RUN composer config --global http-basic.updates.ibexa.co $installation-key $token-password
COPY auth.json /root/.composer/auth.json
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it works here with this path when in docker/apache/Dockerfile I would have to use /root/.config/composer/auth.json?

adriendupuis and others added 8 commits April 1, 2022 18:50
- Composer: Doesn't work with Composer 2, use Composer 1 instead.
- NodeJS, npm & Yarn: `build-essential` avoids "gyp ERR! stack Error: not found: make"
- Index: `php -S` search for index.php than index.html by default. It seems that app_dev.php can't be used as a router for the PHP built-in web server; `CMD service mysql start && php -S 0.0.0.0:8080 -t web app_dev.php` doesn't work.
Both 4.0 and 4.1 are covered so far

# Usage:
# docker build . -f docker/single/Dockerfile-v2 -t ibexa-dxp:v2 && docker run --name ibexa-dxp-v2 --detach --publish 8002:8080 ibexa-dxp:v2;
# docker build . -f docker/single/Dockerfile-v2 --build-arg flavor=commerce --build-arg version=2.5.19 -t ibexa-dxp:v2 && docker run --name ibexa-dxp-v2 --detach --publish 8002:8080 ibexa-dxp:v2;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# docker build . -f docker/single/Dockerfile-v2 --build-arg flavor=commerce --build-arg version=2.5.19 -t ibexa-dxp:v2 && docker run --name ibexa-dxp-v2 --detach --publish 8002:8080 ibexa-dxp:v2;
# docker build . -f docker/single/Dockerfile-v2 --build-arg flavor=ezcommerce --build-arg version=2.5.19 -t ibexa-dxp:v2 && docker run --name ibexa-dxp-v2 --detach --publish 8002:8080 ibexa-dxp:v2;

@adriendupuis
Copy link
Owner Author

adriendupuis commented Aug 17, 2022

The following script (WIP) is testing every 3.3 update from every previous patch version for every flavor

#!/usr/bin/env zsh

githubToken=;

set -x;

targetPatch=24;

docker rm -vf ibexa-dxp-v3;
docker rmi -f ibexa-dxp:v3;

for patch in {1..$((targetPatch-1))..1}; do
for flavor in content experience commerce; do

docker build . -f docker/single/Dockerfile-v3 --build-arg flavor=$flavor --build-arg version=3.3.$patch -t ibexa-dxp:v3;
if [[ $? -gt 0 ]]; then
  continue;
fi;
docker run --name ibexa-dxp-v3 --detach --publish 8003:8080 ibexa-dxp:v3;

sleep 3;
curl --no-progress-meter http://localhost:8003/ | grep "Welcome to" -A2;
curl --no-progress-meter -L http://localhost:8003/admin/login_check -X POST -F _username=admin -F _password=publish -F _csrf_token=$(curl --no-progress-meter http://localhost:8003/admin/login -c cookie.txt | grep _csrf_token | sed -E 's/.*value="([^"]+)".*/\1/') -b cookie.txt -c cookie.txt | grep "Ibexa .* " -A1;

if [ -n $githubToken ]; then
  docker exec ibexa-dxp-v3 composer config --global github-oauth.github.com $githubToken --no-interaction;
fi

# Update Flex
if [ $patch -le 9 ]; then
  docker exec ibexa-dxp-v3 composer update symfony/flex --no-plugins --no-scripts --no-interaction; # fix endpoint usage by old symfony/flex like the too old v1.15.3 from 3.3.8
fi;
if [ $patch -le 15 ]; then
  docker exec ibexa-dxp-v3 composer config extra.symfony.endpoint "https://api.github.com/repos/ibexa/recipes/contents/index.json?ref=flex/main" --no-interaction;
fi;

# Update Symfony and packages
if [ $patch -le 5 ]; then
  docker exec ibexa-dxp-v3 sed -i -E 's/"symfony\/(.+)": "5\.2\..*"/"symfony\/\1": "5.3.*"/' composer.json; # http://localhost:8007/en/latest/updating/from_3.3/update_from_3.3/#v336
  docker exec ibexa-dxp-v3 sed -i -E 's/"require": "5\.2\..*"/"require": "5.3.*"/' composer.json; # http://localhost:8007/en/latest/updating/from_3.3/update_from_3.3/#v336
  if [ $patch -le 1 ]; then
    docker exec ibexa-dxp-v3 composer update "symfony/*" --with-all-dependencies --no-scripts --no-interaction;
  else
    docker exec ibexa-dxp-v3 composer update "symfony/*" --no-scripts --no-interaction;
  fi;
  docker exec ibexa-dxp-v3 composer require symfony/workflow 5.4.* --no-scripts --no-interaction; # Maybe more accurate: 5.4.*
  docker exec ibexa-dxp-v3 sed -i -E 's/"sensio\/framework-extra-bundle": ".?5\..+"/"sensio\/framework-extra-bundle": "^6.1"/' composer.json; # TODO
  docker exec ibexa-dxp-v3 sed -i -E 's/"doctrine\/doctrine-bundle": ".?2\.3\..+"/"doctrine\/doctrine-bundle": "^2.4"/' composer.json; # TODO
  docker exec ibexa-dxp-v3 composer require ibexa/$flavor:3.3.6 --with-all-dependencies --no-scripts --no-interaction;
fi;
if [ $patch -le 12 ]; then
  docker exec ibexa-dxp-v3 composer config allow-plugins true --no-interaction; # NOT recommended; due to automation and the use of --no-interaction; regular user should use interaction and accept plugins' scripts to be added to allow-plugins
  docker exec ibexa-dxp-v3 sed -i -E 's/"symfony\/(.+)": "5\.3\..*"/"symfony\/\1": "5.4.*"/' composer.json; # https://doc.ibexa.co/en/3.3/updating/from_3.3/update_from_3.3/#3315
  docker exec ibexa-dxp-v3 sed -i -E 's/"require": "5\.3\..*"/"require": "5.4.*"/' composer.json; # https://doc.ibexa.co/en/3.3/updating/from_3.3/update_from_3.3/#3315
  docker exec ibexa-dxp-v3 sed -i -E '/ *timeout: [0-9]+/d' ./config/packages/nelmio_solarium.yaml ./config/packages/ezcommerce/ezcommerce_advanced.yaml; # Unrecognized option "timeout" under "nelmio_solarium.endpoints.default".
  docker exec ibexa-dxp-v3 composer update "symfony/*" --no-scripts --no-interaction;
fi;

# Update to targeted Ibexa DXP
#docker exec -ti ibexa-dxp-v3 composer require ibexa/$flavor:3.3.$targetPatch --with-all-dependencies --no-scripts --no-interaction;
docker exec -ti ibexa-dxp-v3 composer update ibexa/$flavor --with-all-dependencies --no-scripts --no-interaction;

# Update Ibexa DXP recipe
if [ $patch -le 7 ]; then
  #docker exec ibexa-dxp-v3 composer recipes:install ibexa/$flavor --force --no-interaction;
  docker exec ibexa-dxp-v3 sed -i -E "/^\];/i\    Hautelook\\\TemplatedUriBundle\\\HautelookTemplatedUriBundle::class => ['all' => true]," config/bundles.php;
fi;

# Update database
if [ $patch -le 6 ]; then
  docker exec -i ibexa-dxp-v3 mysql -uroot ibexa < vendor/ibexa/installer/upgrade/db/mysql/ibexa-3.3.6-to-3.3.7.sql; # http://localhost:8007/en/latest/updating/from_3.3/update_from_3.3/#v337
  if [ 'commerce' = $flavor ]; then
    sleep 1;
    docker exec ibexa-dxp-v3 mkdir --parent src/Migrations/Ibexa/migrations;
    docker exec ibexa-dxp-v3 cp vendor/ibexa/installer/src/bundle/Resources/install/migrations/content/Components/move_configuration_to_settings.yaml src/Migrations/Ibexa/migrations/;
    docker exec ibexa-dxp-v3 php bin/console ibexa:migrations:migrate --file=move_configuration_to_settings.yaml; # https://doc.ibexa.co/en/latest/updating/from_3.3/update_from_3.3/#v337
  fi;
fi;
if [ $patch -le 8 ]; then
  docker exec -i ibexa-dxp-v3 mysql -uroot ibexa < vendor/ibexa/installer/upgrade/db/mysql/ibexa-3.3.8-to-3.3.9.sql; # https://doc.ibexa.co/en/3.3/updating/from_3.3/update_from_3.3/#v339
fi;

if [ 'content' != $flavor ]; then
  #needed since 3.3.23 or .24
  docker exec ibexa-dxp-v3 composer run post-install-cmd;
  curl --no-progress-meter http://localhost:8003/ | grep "Welcome to" -A2;
  sleep 1;
  docker exec ibexa-dxp-v3 php bin/console cache:clear;
fi;

curl --no-progress-meter http://localhost:8003/ | grep "Welcome to" -A2;
curl --no-progress-meter -L http://localhost:8003/admin/login_check -X POST -F _username=admin -F _password=publish -F _csrf_token=$(curl --no-progress-meter http://localhost:8003/admin/login -c cookie.txt | grep _csrf_token | sed -E 's/.*value="([^"]+)".*/\1/') -b cookie.txt -c cookie.txt | grep "Ibexa .*&nbsp;" -A1;
rm cookie.txt;

docker rm -vf ibexa-dxp-v3;
docker rmi -f ibexa-dxp:v3;

done;
done;

#docker system prune --all --force --volumes;

#ARG installation-key
#ARG token-password
ARG flavor=ezplatform-ee
ARG version=2.5.31
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ARG version=2.5.31
ARG version=2.5.32

ARG flavor=ezplatform-ee
ARG version=2.5.31
#ARG flavor=ezcommerce
#ARG version=2.5.20
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ARG version=2.5.20
#ARG version=2.5.21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant