DEV Community

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

Collapse
 
veevidify profile image
V

Are you setting up a new Laravel project or trying to create docker environment for existing one?

If you are setting up new Laravel project, you can refer to my repo:
github.com/veevidify/laravel-apach...

and then do:

docker-compose build
docker-compose up -d
docker-compose logs -f
Collapse
 
manishsharmait52 profile image
manishsharmait52

Thank you so much to reply me , i will check it and let you know if i am facing another issue .

Thank you again ..... !

Thread Thread
 
manishsharmait52 profile image
manishsharmait52

Hello Sir, I facing 500 server error issue , can you please give me some tips. what happens over there ?

Collapse
 
tenerecodes profile image
tenerecodes

HI there, i am setting an new project with the latest laravel repo + your dockerfile and docker-compose.yml i get this error:

Step 13/14 : RUN useradd -G www-data,root -u $uid -d /home/devuser devuser
---> Running in e24b11b14717
useradd: invalid user ID '-d'
ERROR: Service 'laravel-app' failed to build: The command '/bin/sh -c useradd -G www-data,root -u $uid -d /home/devuser devuser' returned a non-zero code: 3

any solution ?

Thread Thread
 
veevidify profile image
V • Edited

If you refer back to docker-compose.yml, this part:

...
      args:
        uid: ${UID}

docker-compose requires UID environment variable to be set. Check your .env file, make sure

UID=1000 # or whatever your host's user id is

If you're unsure about host user id, type id in your terminal to double check.

Thread Thread
 
tenerecodes profile image
tenerecodes

That worked fine thank you. but i have another question, if you permit, regarding your Dockerfile. how to copy npm from nodejs docker image like you did with composer.

the reason i ask this is because when i run "php artisan ui vue --auth" i get this message:

Vue scaffolding installed successfully.
Please run "npm install && npm run dev" to compile your fresh scaffolding.
Authentication scaffolding generated successfully.

Thread Thread
 
veevidify profile image
V • Edited

There is a neat little trick to run a docker container as if it's a binary in your host. This is very useful for things like composer or npm which only modifies files statically. Example:

$ cd /your/project/folder
$ docker run -it -u 1000:1000 -v "$PWD":/usr/src/app -w /usr/src/app --rm node:10 npm install

Make sure all the parameters are what you need, e.g. uid, node version, etc.

Even though I copy composer binary into the my own app image for "encapsulation", if we intend to only ever use such binary for static files modification on the host, that wouldn't be necessary. Instead this trick makes it more clean once you start having 5 6 container runtime for these sorts of purposes.

I conveniently "missed out" this part due to how varied people's use cases with node are.