From 5de922d8eecdfa56e626a687908a1ebb57afb1d1 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sat, 15 Apr 2023 04:02:41 -0700 Subject: [PATCH] Fix not found npm dev container node_modules, new entrypoint --- frontend/Dockerfile | 10 ++++++---- frontend/entrypoint.sh | 9 +++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100755 frontend/entrypoint.sh diff --git a/frontend/Dockerfile b/frontend/Dockerfile index e662f607..188ef108 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -5,13 +5,15 @@ RUN mkdir -p /usr/src/frontend # specifying the working dir inside the container WORKDIR /usr/src/frontend -# copy current dir's content to container's WORKDIR root i.e. all the contents of the robosats app +# copy current workdir COPY package.json package.json COPY package-lock.json package-lock.json +COPY entrypoint.sh entrypoint.sh +RUN chmod +x entrypoint.sh -# packages we use +# install packages RUN npm install +RUN mv node_modules /tmp/node_modules -# launch - +ENTRYPOINT [ "/usr/src/frontend/entrypoint.sh" ] CMD ["npm", "run", "build"] \ No newline at end of file diff --git a/frontend/entrypoint.sh b/frontend/entrypoint.sh new file mode 100755 index 00000000..b0ad8df5 --- /dev/null +++ b/frontend/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Copy node_modules if it doesn't exist +if [ ! -f "/usr/src/frontend/node_modules" ]; then + echo "Looks like the first run of this container. Node modules were not detected on the attached volume, copying them into the attached volume." + cp -R /tmp/node_modules /usr/src/frontend/node_modules +fi + +exec "$@"