Closed romainreignier closed 6 months ago
Thanks for documenting this, yeah that was a last minute sloppy patch.. I have been meaning to circle back & clean this up. I believe this was causing issues here: https://github.com/calebolson123/BabySleepCoach/issues/21
Regarding mounting single files, I agree it's tedious & ugly. Do you have any cleaner ideas for preserving modifications to these files through container destruction?
Move these files to a subdir and only mount this subdir.
It could be src
.
6 oct. 2023 15:18:45 calebolson123 @.***>:
Regarding mounting single files, I agree it's tedious & ugly. Do you have any cleaner ideas for preserving modifications to these files through container destruction?
— Reply to this email directly, view it on GitHub[https://github.com/calebolson123/BabySleepCoach/issues/24#issuecomment-1750669534], or unsubscribe[https://github.com/notifications/unsubscribe-auth/ACDPSYAVRJIFRXKQLAMPWFDX6AALHAVCNFSM6AAAAAA5VWQBAKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJQGY3DSNJTGQ]. You are receiving this because you authored the thread. [Image de pistage][https://github.com/notifications/beacon/ACDPSYCSVSFK7UZEABH5IWLX6AALHA5CNFSM6AAAAAA5VWQBAKWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTILEMN4.gif]
Possible Solutions:
Example in docker-compose.yml:
services:
webapp:
build: .
volumes:
- .:/usr/app/babysleepcoach
- /usr/app/babysleepcoach/webapp/node_modules
This configuration mounts the current directory into the container but excludes the node_modules directory from being overwritten.
Modify the container's startup command to run yarn install before starting the application. This ensures that node_modules is populated each time the container starts.
Considerations:
The first approach is more efficient since it avoids reinstalling dependencies every time the container starts, which can be time-consuming. This is what I'm currently doing and it seems to be working fine.
The second approach ensures that the container always has the most up-to-date dependencies but can slow down the startup process.
in case anyone is having the same issue. Using the @sabes23 suggestion, the docker compose look like this.
services:
baby-sleep-coach:
build:
dockerfile: ./Dockerfile
context: .
ports:
- "0.0.0.0:${PORT}:80"
- "0.0.0.0:8000:8000"
- "0.0.0.0:8001:8001"
env_file:
- .env
volumes:
- .:/usr/app/babysleepcoach
- /usr/app/babysleepcoach/webapp/node_modules
# To use a webcam, uncomment these lines
# devices:
# - /dev/video0
Thanks @appleimperio @sabes23 @romainreignier, brought these changes into https://github.com/calebolson123/BabySleepCoach/pull/36 along w/ some other snags i ran into on testing this project on a fresh install
During the build step of the Docker image,
yarn install
is called and generates anode_modules
directory inwebapp
. This operation installsreact-scripts
used to start the web app. But by mounting the current host dir in the container overrides the/usr/app/babysleepcoach
directory content and thewebapp/node_modules
is not present anymore, resulting in the error ondocker-compose up
:Only mounting single files is working but tedious: