invoiceninja / dockerfiles

Docker files for Invoice Ninja
https://hub.docker.com/r/invoiceninja/invoiceninja
GNU General Public License v2.0
418 stars 268 forks source link

Fix Docker builds for circular dependency in project #561

Closed anojht closed 10 months ago

anojht commented 10 months ago

Due to the circular dependency of livewire JS module from composer, without intermediate build stages, the Docker build fails during the vite build step due to missing livewire module.

The changes here allow composer install to run then copies the vendor folder to an intermediate stage in order to complete the vite build with the livewire dependency being present.

Then the contents are copied back in another intermediate stage to the php environment to complete the build.

turbo124 commented 10 months ago

@anojht

Thanks for this, i've been working on this also, however testing the build process here is failing for me also:

 => ERROR [dependencybuild 2/2] RUN --mount=target=/var/www/app/node_modules,type=cache  npm install  && npm run production  && mv /var/www/app/storage /var/www/app/docker-backup-storage/  && mv /var/www/app/public /var/www/app/docker-backup-public/           0.8s
------
 > [dependencybuild 2/2] RUN --mount=target=/var/www/app/node_modules,type=cache        npm install     && npm run production   && mv /var/www/app/storage /var/www/app/docker-backup-storage/  && mv /var/www/app/public /var/www/app/docker-backup-public/:
0.711 npm ERR! Tracker "idealTree" already exists
0.712 
0.712 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-01-21T06_31_19_252Z-debug-0.log
------
Dockerfile:108
anojht commented 10 months ago

@anojht

Thanks for this, i've been working on this also, however testing the build process here is failing for me also:

 => ERROR [dependencybuild 2/2] RUN --mount=target=/var/www/app/node_modules,type=cache  npm install  && npm run production  && mv /var/www/app/storage /var/www/app/docker-backup-storage/  && mv /var/www/app/public /var/www/app/docker-backup-public/           0.8s
------
 > [dependencybuild 2/2] RUN --mount=target=/var/www/app/node_modules,type=cache        npm install     && npm run production   && mv /var/www/app/storage /var/www/app/docker-backup-storage/  && mv /var/www/app/public /var/www/app/docker-backup-public/:
0.711 npm ERR! Tracker "idealTree" already exists
0.712 
0.712 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-01-21T06_31_19_252Z-debug-0.log
------
Dockerfile:108

Hi, it has been fixed, the WORKDIR had not been set before the npm install step. Sorry the Dockerfile in this repo is quite different than my own fork, where I originally implemented and tested the fix: anojht/invoiceninja, so it took a bit of time to adapt the fix.

turbo124 commented 10 months ago

Thanks! looks good.