zsoerenm/magento2-docker

Default domain exception

ziedbf opened this issue · 1 comments

HI @zsoerenm

I appreciate the tremendous work that you achieved to setup magento over docker containers. I have one issue trying to solve that raise during both build and run stages. I included all the needed app files from magento to the docker volume mount under php containers, and update the mariadb database with the needed data:

version: '3'
services:

  sslproxy:
    build:
      context: .
      dockerfile: sslproxy/Dockerfile
    depends_on:
      - varnish
    ports:
      - "443:443"
      - "80:80"
    volumes:
      - ./certs/localhost+2-key.pem:/etc/nginx/ssl/nginx.key
      - ./certs/localhost+2.pem:/etc/nginx/ssl/nginx.crt
    environment:
      - BACKEND_HOST=varnish
      - SERVER_NAME=localhost

  varnish:
    image: zsoerenm/magento2-varnish:2.2.6
    depends_on:
      - web

  redis:
    image: redis:alpine

  web:
    build:
      context: .
      dockerfile: nginx/Dockerfile
    depends_on:
      - php
    volumes:
      - mediadata:/var/www/html/pub/media:ro
      - appdata:/var/www/html:ro
#      - ./src/app/code:/var/www/html/app/code:ro
#      - ./src/vendor/<some_vendor>:/var/www/html/vendor/<some_vendor>:ro
    environment:
      - BACKEND_HOST=php
      - SERVER_NAME=web

  php:
    build:
      context: .
      dockerfile: php/Dockerfile
    depends_on:
      - db
    volumes:
      - ./src/app:/var/www/html/app
      # - mediadata:/var/www/html/pub/media
      # - configdata:/var/www/html/app/etc
      # - appdata:/var/www/html
     #  - ./src/vendor/<some_vendor>:/var/www/html/vendor/<some_vendor>
    environment:
      - DEFAULT_CACHE_REDIS_SERVER=redis
      - DEFAULT_CACHE_REDIS_DATABASE=1
      - PAGE_CACHE_REDIS_SERVER=redis
      - PAGE_CACHE_REDIS_DATABASE=2
      - SESSION_REDIS_SERVER=redis
      - SESSION_REDIS_DATABASE=3

  db:
    image: mariadb:10.2
    volumes:
      - dbdata:/var/lib/mysql
    healthcheck:
      test: 'mysqladmin ping --silent'
    environment:
      - MYSQL_ROOT_PASSWORD=magento2
      - MYSQL_DATABASE=magento2
      - MYSQL_USER=magento2
      - MYSQL_PASSWORD=magento2

  cron:
    image: zsoerenm/magento2-php:2.2.6
    depends_on:
      - db
    volumes:
      - mediadata:/var/www/html/pub/media
      - configdata:/var/www/html/app/etc
      - appdata:/var/www/html
    entrypoint: "su magento -s /bin/sh -c 'trap exit TERM; while :; do bin/magento cron:run; sleep 1m & wait $${!}; done;'"

volumes:
  dbdata:
  appdata:
  mediadata:
  configdata:

The app folders include all needed folder to setup my app code, design and etc folders and the etc folder include all the needed configuration env.php, config.php and finally update php docker file to enable all plugins:

....
&& php bin/magento module:enable --all \
&& php bin/magento setup:di:compile \
&& php bin/magento setup:static-content:deploy -f -q -j=2 \
....

However for some reason i hit an error related to default website is not defined:

+ php bin/magento setup:di:compile
Compilation was started.
%message% 0/7 [>---------------------------]   0% < 1 sec 34.0 MiB%message% 0/7 [>---------------------------]   0% < 1 sec 34.0 MiBProxies code generation... 0/7 [>------------------------]   0% < 1 sec 34.0 MiB
Proxies code generation... 1/7 [===>---------------------]  14% < 1 sec 40.0 MiB
Repositories code generation... 1/7 [==>-----------------]  14% < 1 sec 40.0 MiB
Repositories code generation... 2/7 [=====>--------------]  28% 9 secs 114.0 MiB
Service data attributes generation... 2/7 [====>---------]  28% 9 secs 114.0 MiB
Service data attributes generation... 3/7 [=====>-------]  42% 10 secs 114.0 MiB
Application code generator... 3/7 [=====>-------]  42% 10 secs 114.0 MiB
Application code generator... 4/7 [=======>-----]  57% 20 secs 130.0 MiB
Interceptors generation... 4/7 [=======>-----]  57% 20 secs 130.0 MiB
Interceptors generation... 5/7 [=========>---]  71% 42 secs 160.0 MiB
Area configuration aggregation... 5/7 [=========>---]  71% 42 secs 160.0 MiB
Area configuration aggregation... 6/7 [===========>-]  85% 51 secs 252.0 MiB
Interception cache generation... 6/7 [===========>-]  85% 51 secs 252.0 MiB
Interception cache generation... 7/7 [=============] 100% 56 secs 252.0 MiB
Generated code and dependency injection configuration successfully.
+ php bin/magento setup:static-content:deploy -f -q '-j=2'

In WebsiteRepository.php line 159:

  The default website isn't defined. Set the website and try again.

, apply some changes to enable default_store within the database per this thread, but with no success.

Any idea on what could be the root cause for such problem? or could you point to some approach to debug it?