How to initialize a Git Submodule in Dockerfile

1.4k Views Asked by At

In my recent project I've come to use Git Submodules, however I'm struggling to get my Docker container to download the information from the submodule on deployment.

Here's my Dockerfile (disclaimer: I am using CapRover, so their Dockerfile is formatted different, but everything is the same):

        "FROM library/node:16.6.0-alpine",
        "RUN apk update && apk upgrade &&     apk add --no-cache git", 
        "RUN mkdir -p /usr/src/app",
        "WORKDIR /usr/src/app",
        "COPY ./package.json /usr/src/app/",
        "RUN npm install --production && npm cache clean --force",
        "WORKDIR ./Status-Plus-Translation/",
        "RUN git submodule update --recursive --remote",
        "WORKDIR /usr/src/app",
        "COPY ./ /usr/src/app",
        "ENV NODE_ENV production",
        "ENV PORT 80",
        "EXPOSE 80",
        "CMD [ \"npm\", \"start\" ]"

For clarification, this is what my project's files look like:

enter image description here

When I run the top Dockerfile code, I get the following error:

enter image description here

0

There are 0 best solutions below