Deploy another repository in current configuration

I have already Caddy configured with git plugin. Now I have made a seprate and new repository which I want to deploy on my web page. This new repository is made with create-react-app and react, and the one I am already hosting is made with plain JS if that matter.

I have tried to just do git clone, but I get a warning and suggestion about using submodules. I tried submodule, but I dont think that is the right solution.

Hi @andymoose, can you elaborate on what you’ve tried? Specific commands you’ve used, error messages you’ve received, and your current Caddyfile will help us understand what’s happening.

Here is my Caddyfile! Tell me if I am sladding over something important info u need

When I have it as a submodule(?), I can run the reactrepo with local host, but when I go to my-site.com/reactrepo I get a 404.

This is what I get when I do git clone:

And when I push to github my repo looks like this:

It doesn’t look like you have added a submodule at all. It looks like you’ve just moved another repo inside the first repo and tried to add it, which doesn’t work when other people (read: Caddy servers) try to pull the main repo. The message you get when you git add . explains this.

I assume the embedded repo is meant to be available at the /reactrepo path? I can’t see any other folder in the repo that looks like it might be called /reactrepo, but you have blanked some out.

That is correct that I want the embedded repo to be available at /reactrepo! Reactrepo was just a placeholder for ‘blankspill’

You need to actually add the second repo as a submodule to the main repo. The warning/hint message explains how to do that.

Then, because git cloning doesn’t automatically initialise and clone submodules, you need to add a flag to the git command that Caddy uses to grab the files.

The Caddy git directive lets you specify additional flags for cloning and pulling - the clone_args and pull_args subdirectives. The flag you want is --recurse-submodules.

https://git-scm.com/book/en/v2/Git-Tools-Submodules
https://caddyserver.com/docs/http.git

@Whitestrake where do I find the git directive?

That would be this one:

Where should I do this? My .gitmodules now contain :

[submodule "blank"]
	path = blank
	url = https://github.com/myname/blankspill.git

Should maybe also mention that I have made my repository private so the git plugin I had installed is turned off I guess

In your Caddyfile. You need Caddy itself to recurse the submodules when it pulls the main repo, so it gets everything. Otherwise it’ll only get the main repo, regardless of the submodule.

Well, that’s going to make things difficult, because when Caddy pulls the repo, it does it anonymously. You’ll need to add an SSH key and specify it in the git directive, too, so that Caddy can authenticate to Github and pull the private repo.

https://caddyserver.com/docs/http.git

Caddyfile now:
bilde

And I made it public again so I dont have to add any more in my Git directive. If I wanted, where do I find my sshkey lol? I know I have made one before, but it is a long time ago.

What do I miss to do now to finish?

I think that’s all you need, as long as the repository itself it set up correctly with the submodules, Caddy should fetch them.

Hmm! It does not work:(:frowning:

What info should I post?

When troubleshooting, useful information to supply includes:

  1. What did you try? (Post configuration, logs, HTTP requests, etc)
  2. What result did you expect? (e.g. a webpage with XYZ content)
  3. What did you see instead? (e.g. a 404, or the wrong page, etc)
  1. This is what I have now

and .gitmodules contain this:

[submodule “blank”]
path = blank
url = GitHub - andrinelo/blankspill
  1. Expected to see the repository on myPage.com/blank
  2. But instead I see 404

Does the webroot index work?

After Caddy starts up and pulls the repo, is the blank directory present under the webroot? Is there anything inside it?

webPage.com does work is that is what you meant with “does the webroot index work”

I dont know how to check if blank directory is present under the webroot, how do I check it? Since I get a 404, could it be that I miss it some how in the index file?

You’ll need to browse to the actual location of the files on disk after Caddy’s pulled the repo - like, with a file explorer or in a terminal - and look at them.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.