mardi 16 avril 2019

How to run migration to a database that live in a Docker - Laravel 5.8?

I'm on a Mac OS X, and have a docker-compose.yml

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

I also have a 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
CMD php artisan migrate
CMD php artisan serve --host=0.0.0.0

Note : I have this line CMD php artisan migrate

The container seems to build and start successfully when I ran docker-compose up, I can also connect to the database, but I don't see any tables.

Where should I put this line php artisan migrate ?


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