Docker4drupal: 404 for all theme assets

Created on 15 Dec 2016  路  7Comments  路  Source: wodby/docker4drupal

I have tried a few different versions of Drupal 8, but each time get the same result. The installation page loads, but none of the css, js, images load.

This is the how I have the php service configured:

php:
    image: wodby/drupal-php:7.0 # Allowed: 7.0, 5.6.
    environment:
      PHP_SITE_NAME: dev
      PHP_HOST_NAME: localhost:8000
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
    volumes:
      - ./drupal:/var/www/html

I have also tried with drupal files in the root, with:

    volumes:
      - ./:/var/www/html

So, the php pages are being found and servered, but not the themes. I dont think it is anything to do with drupal being misconfigured as I have tried two different, minor, versions of Drupal 8, that are fresh, unaltered.

I have tried running docker compose as sudo, and giving 777 to the docker4drupal folder, and all files.

Here is the directory and file permissions for the php service:

docker-compose exec php ls -lah /var/www/html/
total 456
drwxrwxrwx   11 1000     127         4.0K Dec 17 14:43 .
drwxr-xr-x    3 www-data www-data    4.0K Nov 26 10:47 ..
-rwxrwxrwx    1 1000     1000         948 Dec  7 18:31 .csslintrc
-rwxrwxrwx    1 1000     1000         350 Dec  7 18:31 .editorconfig
-rwxrwxrwx    1 1000     1000         185 Dec  7 18:31 .eslintignore
-rwxrwxrwx    1 1000     1000          36 Dec  7 18:31 .eslintrc
drwxrwxrwx    8 1000     1000        4.0K Dec 15 17:19 .git
-rwxrwxrwx    1 1000     1000        3.6K Dec  7 18:31 .gitattributes
-rwxrwxrwx    1 1000     1000          23 Dec 15 17:19 .gitignore
-rwxrwxrwx    1 1000     1000        7.7K Dec 15 21:28 .htaccess
-rwxrwxrwx    1 1000     1000       17.7K Nov 16 23:57 LICENSE.txt
-rwxrwxrwx    1 1000     1000       12.4K Dec 15 17:19 README.md
-rwxrwxrwx    1 1000     1000        5.8K Dec  7 18:31 README.txt
-rwxrwxrwx    1 1000     1000         262 Dec  7 18:31 autoload.php
-rwxrwxrwx    1 1000     1000        1.4K Dec  7 18:31 composer.json
-rwxrwxrwx    1 1000     1000      144.4K Dec  7 18:31 composer.lock
drwxrwxrwx   12 1000     1000        4.0K Dec  7 18:31 core
-rwxrwxrwx    1 1000     1000        2.5K Dec 17 14:56 docker-compose.yml
drwxrwxrwx    3 1000     1000        4.0K Dec 15 17:33 docker-runtime
drwxrwxrwx    2 1000     1000        4.0K Dec 17 14:43 drupal
-rwxrwxrwx    1 1000     1000        1.3K Dec  7 18:31 example.gitignore
-rwxrwxrwx    1 1000     1000         549 Dec  7 18:31 index.php
drwxrwxrwx    2 1000     1000        4.0K Dec  7 18:31 modules
drwxrwxrwx    2 1000     1000        4.0K Dec  7 18:31 profiles
-rwxrwxrwx    1 1000     1000        1.6K Dec  7 18:31 robots.txt
drwxrwxrwx    3 1000     1000        4.0K Dec  7 18:31 sites
drwxrwxrwx    2 1000     1000        4.0K Dec  7 18:31 themes
-rwxrwxrwx    1 1000     1000         554 Dec  7 18:31 update.php
drwxrwxrwx   18 1000     1000        4.0K Dec  7 18:53 vendor
-rwxrwxrwx    1 1000     1000        4.4K Dec  7 18:31 web.config

Could nginx be misconfigured?

In the console I see:

ma_1 | 2016-12-15 20:49:42,068 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
php_1 | 172.22.0.6 - 15/Dec/2016:20:50:16 +0000 "GET /index.php" 302
nginx_1 | 172.22.0.1 - - [15/Dec/2016:20:50:16 +0000] "GET / HTTP/1.1" 302 324 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/53.0.2785.143 Chrome/53.0.2785.143 Safari/537.36"
php_1 | 172.22.0.6 - 15/Dec/2016:20:50:16 +0000 "GET /core/install.php" 200
nginx_1 | 172.22.0.1 - - [15/Dec/2016:20:50:16 +0000] "GET /core/install.php HTTP/1.1" 200 3946 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/53.0.2785.143 Chrome/53.0.2785.143 Safari/537.36"
nginx_1 | 2016/12/15 20:50:16 [error] 12#12: *1 open() "/var/www/html/core/assets/vendor/normalize-css/normalize.css" failed (2: No such file or directory), client: 172.22.0.1, server: localhost, request: "GET /core/assets/vendor/normalize-css/normalize.css?0 HTTP/1.1", host: "localhost:8000", referrer: "http://localhost:8000/core/install.php"
nginx_1 | 2016/12/15 20:50:16 [error] 12#12: *4 open() "/var/www/html/core/themes/stable/css/system/components/ajax-progress.module.css" failed (2: No such file or directory), client: 172.22.0.1, server: localhost, request: "GET /core/themes/stable/css/system/components/ajax-progress.module.css?0 HTTP/1.1", host: "localhost:8000", referrer: "http://localhost:8000/core/install.php"
nginx_1 | 2016/12/15 20:50:16 [error] 12#12: *5 open() "/var/www/html/core/themes/stable/css/system/components/align.module.css" failed (2: No such file or directory), client: 172.22.0.1, server: localhost, request: "GET /core/themes/stable/css/system/components/align.module.css?0 HTTP/1.1", host: "localhost:8000", referrer: "http://localhost:8000/core/install.php"

Any idea why this is occurring and how I can fix it?

question

Most helpful comment

I see different volumes if PHP ./drupal/drupal-8.2.4:/var/www/html and Nginx ./drupal:/var/www/html.

All 7 comments

Hi @magick93,

It looks like an issue in nginx service configuration. Please attach the output of the commands:

  • docker-compose exec php ls -la /var/www/html
  • docker-compose exec nginx ls -la /var/www/html

Also, attach nginx config from the docker compose file.

docker-compose exec php ls -la /var/www/html

This output is in the original post.

docker-compose exec nginx ls -la /var/www/html

docker-compose exec nginx ls -la /var/www/html
total 8
drwxr-xr-x    2 root     root          4096 Dec 15 17:44 .
drwxr-xr-x    3 root     root          4096 Oct 14 04:31 ..

Also, attach nginx config from the docker compose file.

  nginx:
    image: wodby/drupal-nginx
    environment:
      NGINX_SERVER_NAME: localhost
      NGINX_UPSTREAM_NAME: php
#      NGINX_DOCROOT: public # Relative path inside the /var/www/html/ directory.
      DRUPAL_VERSION: 8 # Allowed: 7, 8.
    volumes_from:
      - php
    ports:
      - "8000:80"

I tried with variations of the NGINX_DOCROOT setting but never had any joy.

As you can see docroot is empty in Nginx. Are you sure you PHP container called php?

Also, try to replace this block in nginx service definition

    volumes_from:
      - php

by volumes as in php container

volumes:
      - ./drupal:/var/www/html

Thanks for your help.

Yes, the PHP container is called php

I also tried your suggestion of using the same volume, but am still getting the same result.

Here is the complete compose file:

version: "2"

services:
  mariadb:
    image: wodby/drupal-mariadb
    environment:
      MYSQL_RANDOM_ROOT_PASSWORD: 1
      MYSQL_DATABASE: drupal
      MYSQL_USER: drupal
      MYSQL_PASSWORD: drupal
#    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci # The simple way to override the mariadb config.
    volumes:
      - ./docker-runtime/mariadb:/var/lib/mysql
#      - ./docker-runtime/mariadb-init:/docker-entrypoint-initdb.d # Place init .sql file(s) here.

  php:
    image: wodby/drupal-php:7.0 # Allowed: 7.0, 5.6.
    environment:
      PHP_SITE_NAME: dev
      PHP_HOST_NAME: localhost:8000
#      PHP_DOCROOT: public # Relative path inside the /var/www/html/ directory.
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
      # PHP_XDEBUG_ENABLED: 1
      # PHP_XDEBUG_AUTOSTART: 1
      # PHP_XDEBUG_REMOTE_CONNECT_BACK: 0         # This is needed to respect remote.host setting bellow
      # PHP_XDEBUG_REMOTE_HOST: "10.254.254.254"  # You will also need to 'sudo ifconfig lo0 alias 10.254.254.254'
    volumes:
      - ./drupal/drupal-8.2.4:/var/www/html

  nginx:
    image: wodby/drupal-nginx
    environment:
      NGINX_SERVER_NAME: localhost
      NGINX_UPSTREAM_NAME: php
#      NGINX_DOCROOT: public # Relative path inside the /var/www/html/ directory.
      DRUPAL_VERSION: 8 # Allowed: 7, 8.
    volumes:
      - ./drupal:/var/www/html
    ports:
      - "8000:80"

  pma:
    image: phpmyadmin/phpmyadmin
    environment:
      PMA_HOST: mariadb
      PMA_USER: drupal
      PMA_PASSWORD: drupal
      PHP_UPLOAD_MAX_FILESIZE: 1G
      PHP_MAX_INPUT_VARS: 1G
    ports:
     - "8001:80"

  mailhog:
    image: mailhog/mailhog
    ports:
      - "8002:8025"

#  redis:
#    image: redis:3.2-alpine

#  memcached:
#    image: memcached:1.4-alpine

#  memcached-admin:
#    image: phynias/phpmemcachedadmin
#    ports:
#      - "8006:80"

#  solr:
#    image: solr:5.5-alpine
#    volumes:
#      - ./docker-runtime/solr:/opt/solr/server/solr/mycores
#    entrypoint:
#      - docker-entrypoint.sh
#      - solr-precreate
#      - main
#    ports:
#      - "8003:8983"

#  varnish:
#    image: wodby/drupal-varnish
#    depends_on:
#      - nginx
#    environment:
#      VARNISH_SECRET: secret
#      VARNISH_BACKEND_HOST: nginx
#      VARNISH_BACKEND_PORT: 80
#      VARNISH_MEMORY_SIZE: 256M
#      VARNISH_STORAGE_SIZE: 1024M
#    ports:
#      - "8004:6081" # HTTP Proxy
#      - "8005:6082" # Control terminal

#  sshd:
#    image: wodby/drupal-sshd
#    environment:
#      SSH_PUB_KEY: "ssh-rsa ..."
#    volumes_from:
#      - php
#    ports:
#      - "8006:22"

I see different volumes if PHP ./drupal/drupal-8.2.4:/var/www/html and Nginx ./drupal:/var/www/html.

I'm closing this issue, @magick93 if you still have the problem feel free to re-open the issue.

I had the same issue, it was coming from the fact that I did not have the same volumes for Nginx and PHP-FPM. To fix it I used this comment https://github.com/wodby/docker4drupal/issues/71#issuecomment-269444210. Thanks @PavelPrischepa !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dcre picture dcre  路  6Comments

Vacilando picture Vacilando  路  7Comments

quietone1 picture quietone1  路  10Comments

Vacilando picture Vacilando  路  9Comments

pulasthibandara picture pulasthibandara  路  6Comments