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