strapi-community / strapi-tool-dockerize

Easy add support for docker to your strapi project
MIT License
504 stars 34 forks source link

Installing dependencies with npm install doesn't update package.json #88

Closed fl034 closed 8 months ago

fl034 commented 11 months ago

🤷‍♀️ What did you do

I'm coming from a Strapi v3 project, so there my workflow in development phase was to install dependencies inside my running docker container via npm install .... Then my package.json+ lock file would be updated and I could commit it.

With this dockerized approach the file won't change in my git repository.

Am I supposed to change the package.json file by hand and then run RESET with dockerize?

If yes, what are the benefits of this approach?

👩‍💻 Environment

Eventyret commented 11 months ago

You save time having to nom install unless dependencies have changed. This then saves time hence why it's split the way it's split.

fl034 commented 11 months ago

Thx! Answered in one minute. You're faster than any paid support 🚀

Okay the workflow then is to change package.json during development and run docker compose up --build, right?

But shouldn't then the package-lock.json be updated in my git repository so I can commit it?

Eventyret commented 11 months ago

If you are changing package.json then you want to use --build indeed to rebuild the image. If package.json hasn't change then package-lock.json won't change either. So we copy both over then npm install. I guess we could also use npm ci too if you need to keep strict versions etc.

fl034 commented 11 months ago

Yeah so I changed package.json, ran --build, packages were installed correctly, all good. But the package-lock.json which is updated inside the container directory /opt/app is not being synced back to the repository.

IMHO: Would be cool to have for the non-production Dockerfile

Eventyret commented 11 months ago

It should not be synced back. Docker creates an image and state, If your using compose you can bind the file just as much as you bind package.json