vinkla / wordplate

A boilerplate for WordPress, built with Composer and designed with sensible defaults.
2.11k stars 155 forks source link

Error establishing a database connection w/ Docker #205

Closed moimikey closed 6 years ago

moimikey commented 6 years ago

hi,

is there something extra that needs to happen in order to dockerize wordplate? i can't seem to avoid Error establishing a database connection

docker-compose.yml:

version: "3"
services:
  web:
    image: richarvey/nginx-php-fpm:latest
    container_name: web
    ports:
      - "8000:80"
      - "8443:443"
    volumes:
      - ./public:/var/www/html
      - ./vendor:/var/www/html/vendor
      - ./nginx:/etc/nginx/conf.d
      - ./logs/nginx:/var/log/nginx
      - ./certs:/etc/letsencrypt
      - ./certs-data:/data/letsencrypt
    links:
      - mysql
      - redis
    environment:
      - HIDE_NGINX_HEADERS=1
      - ERRORS=1
      - PHP_ERRORS_STDERR=1
      - DOMAIN=vcap.me
      - SKIP_COMPOSER=1
    restart: always

  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    container_name: phpmyadmin
    ports:
      - "1234:80"
    links:
      - mysql
    environment:
      PMA_HOST: mysql
    restart: always

  mysql:
    image: mariadb:latest
    container_name: mysql
    ports:
      - "3306:3306"
    volumes:
      - mariadb_data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
      MYSQL_DATABASE: wordpress
    restart: always

  redis:
    image: redis:latest

volumes:
  mariadb_data:

networks:
  default:
moimikey commented 6 years ago

i figured out the problem... so i had to add extra define's to wp-config.php with the database info. i was assuming this would have been caught automagically with .env somehow. meh.

moimikey commented 6 years ago

also, i feel like maybe vendor and public shouldn't be separate. it's annoying having to alter the path in wordplate's wp-config to point to the correct vendor path.

vinkla commented 6 years ago

Hmm, could you explain why you need to update the vendor path?

moimikey commented 6 years ago

@vinkla the public directory that nginx is using is /var/www/html which is linked to ./public but ./vendor is outside of public, aka outside of /var/www/html which won't work. ./vendor would have to live inside of ./public. it would make more sense if the composer.json lived inside ./public

vinkla commented 6 years ago

You can rename public to html and put everything else outside the html directory.

njxqlus commented 6 years ago

@moimikey Hello, what do you add to wp-config?

moimikey commented 6 years ago

@njxqlus

the only adjustment i made to work with my Docker setup was:

-require __DIR__.'/../vendor/autoload.php';
+require __DIR__.'/vendor/autoload.php';
gabycarol04 commented 4 years ago

how do you modify the wp-config.php