DEV Community

Discussion on: docker-compose up your entire Laravel + Apache + MySQL development environment.

Collapse
 
dhodyrahmad profile image
Dhody Rahmad Hidayat

Hello sir, there's any different configuration between setting up a new Laravel project or trying to create docker environment for existing one?

Collapse
 
veevidify profile image
V • Edited

The difference lies in post containers startup.

So for existing project, we will create all the necessary docker files, such as Dockerfile, docker-compose, place all the configs in place.

Since we're volume mounting the app, depends on what your current setup is missing. If you havent run composer, and there is no vendor folder, you can go ahead and use the container to run composer install. If there is no app key, or passport keys in your setup, you will run respective artisan command to setup.

Similarly, since this setup aims at a new database container, you will start with an empty database (we mount it under var/ inside the project folder). If you have any migrations and seeders, you will need to run those to get a database setup. Alternatively if you have developed a dev database without those migrations and seeders, you can initiate and fill the database with a sql file mounted under run/dump/init.sql as I explained in the post.

Collapse
 
dhodyrahmad profile image
Dhody Rahmad Hidayat

Thank you for your response, I'm newbie in this scope. I have a Laravel application also have migrations and seeders for this application. I've done create necessary docker files and place the configs in place. But there's some problem at migration:

Access denied for user 'root'@'172.19.0.2' (using password: YES)

did I missed something?

Thread Thread
 
veevidify profile image
V

that probably mean your database username and password are not set to what the docker container is built with.

Make sure your environment variables for the mysql service (specified in docker-compose.yml) are consistent with the process you are using to access the database (whatever you are trying that yields that error).