php artisan migration可以工作,但使用应用程序时get QueryException找不到驱动程序错误

时间:2018-11-25 08:45:06

标签: docker laravel-5

我正在将laravel应用程序放入群集集群,这是所有相关文件

Dockerfile来构建laravel应用

FROM composer:1.7 as php-builder

COPY database /database
COPY composer.json composer.json
COPY composer.lock composer.lock

RUN composer install \
  --ignore-platform-reqs \
  --no-interaction \
  --no-plugins \
  --no-scripts \
  --no-dev \
  --optimize-autoloader \
  --prefer-dist

FROM node:11-alpine as frontend-builder

RUN mkdir -p /app/public

COPY package.json webpack.mix.js /app/
COPY resources/assets/ /app/resources/assets/

WORKDIR /app

RUN npm install && npm run production

FROM php:7.2-cli-alpine

COPY . /opt/sabay_quiz
COPY --from=php-builder /app/vendor/ /opt/sabay_quiz/vendor
COPY --from=frontend-builder /app/public/js/ /opt/sabay_quiz/public/js
COPY --from=frontend-builder /app/public/css/ /opt/sabay_quiz/public/css
COPY --from=frontend-builder /app/mix-manifest.json /opt/sabay_quiz/mix-manifest.json

RUN apk update --no-cache && \
  apk upgrade --no-cache && \
  apk add --no-cache postgresql-dev && \
  docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql && \
  docker-php-ext-install pdo pdo_pgsql pgsql && \
  chown -R root:www-data /opt/sabay_quiz && \
  find /opt/sabay_quiz -type f -exec chmod 664 {} + && \
  find /opt/sabay_quiz -type d -exec chmod 775 {} + && \
  chgrp -R www-data /opt/sabay_quiz/storage /opt/sabay_quiz/bootstrap/cache && \
  chmod -R ug+rwx /opt/sabay_quiz/storage /opt/sabay_quiz/bootstrap/cache

CMD ["tail", "-f", "/dev/null"]

php-fpm的Dockerfile

FROM php:7.2-fpm-alpine

EXPOSE 9000

CMD ["php-fpm", "--nodaemonize"]

Docker堆栈文件

version: '3.7'
services:
  app:
    image: laravel_app:latest
    networks:
      - weavenet
      - pg_connect
    deploy:
      replicas: 1
    volumes:
      - laravel_file:/opt/app
    depends_on:
      - postgres_master
    env_file:
      - .env.prod

    postgres_master:
      image: postgres:11-alpine
      networks:
        - weavenet
        - pg_connect
      deploy:
        replicas: 1
      volumes:
        - pg_data:/var/lib/postgresql/data
      env_file:
        - .env.prod.postgres

    php_fpm:
      image: my/php_fpm
      deploy:
        replicas: 3
      volumes:
        - ./php_fpm.www.conf:/usr/local/etc/php-fpm.d/www.conf:ro
        - laravel_file:/opt/app
      networks:
        - weavenet
        - ingress

    proxy:
      image: nginx:1.15-alpine
      depends_on:
        - php_fpm
        - app
      networks:
        - ingress
      ports:
        - 80:80
        - 443:443
      volumes:
        - laravel_file:/opt/app:ro
        - ./nginx.conf:/etc/nginx/conf.d/default.conf

networks:
  weavenet:
    external: true

  ingress:

  pg_connect:
    driver: overlay

volumes:
  laravel_file:
    driver: local

  pg_data:
    driver: local

.env.prod文件

# NOTE: I only shows the .env.prod file because I am pretty sure I
# properly setup on the postgres master node side also because
# the migration I ran from within the app container works and
# I also check the table and seed data does present in the
# postgres master node data
# and inside the .env.prod.postgres only have 3 env vars, those are
# db name, db user and db password

APP_NAME="APP"
...
DB_CONNECTION=pgsql
DB_HOST=postgres_master
DB_PORT=5432
DB_DATABASE=app
DB_USERNAME=user
DB_PASSWORD=user
...

我可以部署堆栈,并且一切都以预期的方式进行设置。将所有容器旋转起来之后。我可以执行到app容器中并成功运行迁移,也可以执行到postgres_master容器中,并查看所有表和种子数据。

问题出在我进入0.0.0.0时,它显示了预期的登录屏幕。但是,当我输入凭据并按Enter键登录时,它向我显示此错误:

error description

注意:堆栈文件不是完美的,并且尚未完成。我计划首先使一切正常,然后在生产使用之前对其进行改进。

0 个答案:

没有答案
相关问题