63
loading...
This website collects cookies to deliver better user experience
git submodules
to deploy correctly to CapRover
using the CapRover CLI
.CapRover
, Docker
and Git
will help you understand how this solution works.caprover deploy
, what happens underneath is that the CLI uses git archive
to make a compressed tar
of your repository. It then sends and deploys that file to your CapRover server.git archive
:.git
directory in the tar
.git submodules
in your repository, they are not downloaded, since the .git
directory is missing.git submodules
in CapRover is to create a Dockerfile
and download the git submodules
as a build step.captain-definition
file and point it to a Dockerfile
.{
"schemaVersion": 2,
"dockerfilePath": "./Dockerfile"
}
Dockerfile
that contains the following build step.RUN git submodule update --init --recursive
FROM node:15-alpine
COPY . .
RUN apk --no-cache add git
# IMPORTANT: Download git submodules
RUN git submodule update --init --recursive
# ...
RUN npm ci
CMD ["node", "src/main"]
caprover deploy
does.tar
file of your repository, while adding the .git
directory.# Archive git repository
git archive HEAD > deploy.tar
# Add `.git` directory to `tar`
tar -rf deploy.tar .git
tar
with the .git
directory, and a Dockerfile
that downloads the git submodules
, you are ready to deploy.# Deploy the `tar` to your CapRover server
npx caprover deploy -t ./deploy.tar
# Remove the tar
rm ./deploy.tar
#!/bin/bash
# Archive git repository
git archive HEAD > deploy.tar
# Add `.git` directory to `tar`
tar -rf deploy.tar .git
# Deploy the `tar` to your CapRover server
npx caprover deploy -t ./deploy.tar
# Remove the tar
rm ./deploy.tar
git submodules
to your CapRover
server.