I am building an app that has a couple different services. I am using docker and docker-compose to build all of the services. However there is some code I need to share between the services, specifically the ORM code. My issue is that when I try to call git submodule update --init
I get the following error:
Step 6/8 : RUN git submodule update --init
---> Running in 88e2dcfa5b36
fatal: Not a git repository: ../.git/modules/my-repo
ERROR: Service 'my-repo' failed to build: The command '/bin/sh -c git submodule update --init' returned a non-zero code: 128
I'm not sure why it's looking in ../
for the .git
directory. I'm pretty sure I set the WORKDIR
correctly. Here is my whole Dockerfile
FROM node
WORKDIR /usr/src/my-repo
COPY package*.json ./
RUN npm install
COPY . .
RUN git submodule update --init
RUN git submodule foreach npm install
CMD ["npm", "start"]
Also as a side note - the submodule is a private repository how would I clone it using SSH? Do I have to set up docker with my ssh key or something? Thanks.
Edit: Also each of the services is a submodule of the parent project. I think that may be why git is looking in ../git/modules/my-repo
but I'm not really sure how to get around this. My directory structure is like so:
parent-repo
--service-1
----orm
--service-2
----orm