xalaida / laravel-nuxt-docker

🦾 Dockerized template for your next project with Laravel and Nuxt.
337 stars 104 forks source link

mysql instead of postgres #7

Closed kevinosburn closed 4 years ago

kevinosburn commented 4 years ago

Hi @nevadskiy

This is very useful... Thanks for putting this together!

Not an "issue", but more of a feature request. What would be the best approach to replace postgres with mysql?

Thanks!

xalaida commented 4 years ago

Hi @kevinosburn.

You're welcome :wink:!

  1. Replace postgres and postgres-testing sections in the docker-compose.yml file with the following code:

    ### MySQL Database ##########################
    mysql:
    image: mysql:5.7
    volumes:
      - database:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=secret
      - MYSQL_USER=app
      - MYSQL_PASSWORD=app
      - MYSQL_DATABASE=app
    ports:
      - 33061:3306
  2. Remove current docker volumes with postgres data running the following command:

    docker-compose down --volumes
  3. Remove docker/postgres directory.

  4. Replace all postgres occurrences in the docker-compose.yml with mysql.

  5. Update your .env database configuration:

    DB_CONNECTION=mysql
    DB_HOST=mysql
    DB_PORT=3306
  6. Add the following code to docker/php-cli/Dockerfile, docker/php-fpm/Dockerfile and docker/supervisor/Dockerfile files replacing # Postgres line:

    # MySQL
    RUN docker-php-ext-install pdo pdo_mysql
  7. Run docker-compose build command, then docker-compose restart.

That should work.

And one question from me, please. Which OS do you use?

kevinosburn commented 4 years ago

Hi @nevadskiy

Thanks for the fast response!

I'm running this on Ubuntu 18.04 and also on a Windows 10 machine.

Oh, just a small typo here... istall should be install

Install composer dependencies: docker-compose exec php-cli composer istall

-Kevin

xalaida commented 4 years ago

@kevinosburn thanks.