Publishing Gitlab wiki?

Oof. Yeah that probably shouldn’t happen.

Hey @vrongmeal could you look into this?

Hey @cphillips . If your config is same as above, the error is because there is no command in the config. You need to provide a command along with the “async” parameter. The error is basically you’re trying to execute a command that does not exist.

   "commands_after": [
      {
        "command": [ "echo", "hello world" ],
        "async": true
      }
    ]

This actually works as a feedback though. Need to improve validation for commands. I’ll definitely take a look at this particular error. Thanks!

3 Likes

I’m still having issues with this!

I am just after a barebones config file to publish the content of the Wiki in Gitlab.

My config now looks like this:


  "apps": {
    "git": {
      "clients": [
        {
          "repo": {
            "url": "http://gitlab.caminfo.local/root/system.wiki.git",
          },
          "service": {
            "type": "poll",
            "interval": "10m"
          },
        }
      ]
    }
  }
}

I enter this in a JSON Schema Validator site and it says everything is ok.

If I then run “caddy validate --config caddy.json” it comes back with:

validate: decoding config: invalid character '}' looking for beginning of object key string

I assume the “service” section does a check and updates the published site every 10 minutes? That’s why I’ve left it in as that is useful… If not, is it safe to remove?

I’m not a JSON expert as you may have noticed!

You can’t have a comma at the end of the url line because it’s the last item in the JSON object.

Unfortunately, JSON is pretty strict about syntax.

Thanks, it’s running now!

Final question, hopefully. How do I get it to actually publish to http://docs.caminfo.local ?

At the moment I am getting nothing displayed in a web browser when I go to http://docs.caminfo.local.

Not sure how I would use the contents of a Caddyfile to specify the destination server etc and also make use of the caddy.json file which I seem to need to run the git plugin.

Also, remember that you can use the caddy adapt command to get JSON from your Caddyfile.

Right, I am back to trying to get this up and running.

This code is working ok, with JSON validation passing:

{
"apps": {
    "git": {
      "clients": [
        {
          "repo": {
            "url": "http://gitlab.caminfo.local/root/system.wiki.git",
            "path": "/var/www"
          },
          "service": {
            "type": "poll",
            "interval": "10m"
          }
        }
      ]
    }
  }
}

However, when I run it, nothing is displayed in a web browser. I believe it’s because there is no code telling it the hostname/details of where the caddy server is running.

I used caddy adapt to generate the JSON for the required hostname (http://docs.caminfo.local) and that gave me this:

{"apps":{"http":{"servers":{"srv0":{"listen":[":80"],"routes":[{"match":[{"host":["docs.caminfo.local"]}],"terminal":true}],"automatic_https":{"skip":["docs.caminfo.local"]}}}}}}

So, how do I merge this information into my JSON file above? I’ve tried several iterations but can’t seem to get it right…

Any help greatfully appreciated! :slight_smile:

Just take the http part and put it beside the one with git (both inside apps). The apps are separate.

So I’ve done this, think it’s what you meant:

{
	"apps": {
		"git": {
			"http": {
				"servers": {
					"srv0": {
						"listen": [":80"],
						"routes": [{
							"match": [{
								"host": ["docs.caminfo.local"]
							}],
							"terminal": true
						}],
						"automatic_https": {
							"skip": ["docs.caminfo.local"]
						}
					}
				}
			},
			"clients": [{
				"repo": {
					"url": "http://gitlab.caminfo.local/root/system.wiki.git",
					"path": "/var/www"
				},
				"service": {
					"type": "poll",
					"interval": "10m"
				}
			}]
		}
	}
}

When I run a caddy validate against it, it is returning:

validate: loading git app module: decoding module config: git: json: unknown field "http"

http doesn’t go inside git, it goes inside apps.

http is an app, git is an app. They are separate, they don’t go inside eachother.

Please look at the JSON structure here:

(And I’m hoping that sometime next month the JSON docs on the website will be able to include the third-party modules.)

1 Like

Matt,

That would be great! I’m a total newbie at this JSON business but am determined to get this up and running.

The support here is brilliant, and appreciated.

{
	"apps": {
		"http": {
			"servers": {
				"srv0": {
					"listen": [":80"],
					"routes": [{
						"match": [{
							"host": ["docs.caminfo.local"]
						}],
						"handle": [{
							"handler": "subroute",
							"routes": [{
								"handle": [{
									"handler": "file_server",
									"hide": ["Caddyfile"]
								}]
							}]
						}],
						"terminal": true
					}]
				}
			}
		},
		"git": {
			"clients": [{
				"repo": {
					"url": "http://gitlab.caminfo.local/root/system.wiki.git",
					"path": "/var/www"
				},
				"service": {
					"type": "poll",
					"interval": "10m"
				}
			}]
		}
	}
}

I’ve now got the above, Caddy is happy with it, saying it’s a valid config.

I then navigate to the page to browse the end result and get the following:

This docs.caminfo.local page can’t be found
No web page was found for the web address: http://docs.caminfo.local/

Before I added in the “file_server” option, which I believe is essential for anything to be displayed, I was just getting a blank page…

Anyone have any thoughts?

Good, that’s progress!

I think you’ll need to at least have root * /var/www (Caddyfile directive) to tell Caddy where to serve files from. You might also want to enable encode gzip for compression.

I don’t know how your wiki is structured. You’ll likely need to use the templates directive plus push some files to the wiki repo as a layout wrapper around your markdown pages:

Francis,

The wiki is just a set of .md files with an uploads folder containing images. Bog standard so to speak.

Alright - so you’ll want to add in an index.html file that acts as your template entrypoint. You’ll rewrite all requests to that file, like rewrite * /index.html. Using the templates, you can grab the original path and load the markdown file requested. See the Caddy website repo for an example:

Does anyone have an example of this working?

It’s all starting to get a bit beyond me unfortunately!

Unfortunately, your request is very much specific to your unique situation. All the information you need is available, you just need to put the pieces together to make it work.

That’s the thing, I thought several people would use Gitlab Wiki to publish documentation as it can do some great stuff and I love the fact you can take a screen shot and literally copy and paste it into your document.

I was starting to look at setting up Gitlab Pages which achieves the same thing but Caddy seemed much simpler!

I also looked at mkdocs which produces nice output but couldn’t seem to find support for dragging and dropping/copying and pasting images to it.

I almost gave in and tried to get this working on Caddy 1 today but then realised this wasn’t the right route to take!

This topic was automatically closed after 30 days. New replies are no longer allowed.