mardi 16 avril 2019

Connection refuse during Migration inside the Docker - Laravel 5.8

I can not seem to be able to make a migration while during my docker build

I've tried

docker-compose.yml

version: '3'
services:
  portalmodules:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 8011:8000
    links:
      - database
  database:
    image: postgres:11.2
    ports:
    - "5432:5432"
    expose:
    - "5432"
    environment:
      - "POSTGRES_PASSWORD=12345"
      - "POSTGRES_USER=john"
      - "POSTGRES_DB=api"

Dockerfile

FROM composer:1.8.5 as build_stage

COPY . /src
WORKDIR /src
RUN composer install

FROM alpine:3.8
RUN apk --no-cache add \
php7 \
php7-mbstring \
php7-session \
php7-openssl \
php7-tokenizer \
php7-json \
php7-pdo \
php7-pdo_pgsql \
php7-pgsql

COPY --from=build_stage /src  /src
RUN ls -al
RUN set -x \
addgroup -g 82 -S www-data \
adduser -u 82 -D -S -G www-data www-data

WORKDIR /src
RUN ls -al
RUN chmod -R 777 storage
RUN chmod +x run.sh
RUN cp run.sh /tmp
ENTRYPOINT ["/tmp/run.sh"]

run.sh

#!/bin/sh

php artisan migrate:fresh --seed
php artisan serve --host=0.0.0.0

.env

APP_NAME=API
APP_ENV=local
APP_KEY=base64:Qa3U2oP5IQ93MGEJu61MrcQFRSsS5vQRWUrqYwIplEo=
APP_DEBUG=true
APP_URL=http://1.1.1.1
#---------------------------------------------- DATABASE
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=api
DB_USERNAME=john
DB_PASSWORD=12345

I've tried 3 diff values of DB_HOST localhost, 127.0.0.1, database

I kept getting

enter image description here


Questions

How would one go about and debug this further ?


I'm open to any suggestions at this moment.

Any hints/suggestions / helps on this be will be much appreciated!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire