Docker and submodules
stavros-tsioulis
PROOP

a year ago

Hi, I have a monorepo project with some of the packages stored as submodules.

Unless I'm wrong, there's no way to fetch the submodules in the install step while deploying. So, according to this thread: Any idea how to work with github submodules? - Railway Help Station, I've set up this dockerfile:

FROM node:22
WORKDIR /usr/src/app
COPY . .
RUN npm install -g pnpm
RUN git submodule update --init --recursive
RUN pnpm install
EXPOSE 3000
CMD ["pnpm", "start"]

However, it appears the ".git" directory is not copied, making it not possible fetch the submodules inside it. Even including it explicitly with COPY . .git ./ does not work because the directory does not exist.

How can we deploy projects that rely on submodules? Do we have to work with artifact servers?

3 Replies

a year ago

Hello,

The .git folder is indeed not copied, in your Dockerfile you would need to login and register with the repo to then pull the submodules.


brody

Hello,The .git folder is indeed not copied, in your Dockerfile you would need to login and register with the repo to then pull the submodules.

stavros-tsioulis
PROOP

a year ago

Thanks for the response! If the .git directory is not copied, then that sounds like we’d need to initialize a repository inside the Dockerfile with git init , right? Otherwise, git commands wouldn’t work.

Although, still, it would be very tricky to do with ssh… do we copy over the private key directly as an environment variable, or make an internal service where secrets like these are stored (or even better some secrets management service like Vault, etc.)?

It would be great if we had direct support for submodules, because at this moment it sounds simpler to make an internal artifacts service and download the submodules to fill in the gaps.


a year ago

Yep you would need to init a git repo.

Yes you would want to auth the git cli tool with environmental variables, they can be stored as service variables.

If you'd like to see us natively support this, please upvote this thread as that is how we know what features our users want!


Loading...