Fix not found npm dev container node_modules, new entrypoint

This commit is contained in:
Reckless_Satoshi 2023-04-15 04:02:41 -07:00
parent dfb399c55f
commit 5de922d8ee
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
2 changed files with 15 additions and 4 deletions

View File

@ -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"]

9
frontend/entrypoint.sh Executable file
View File

@ -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 "$@"