I need to write some documentation for a system and like to make use of the Gitlab wiki feature.
Is there a way to publish this content from the wiki to a static website using Caddy 2? I see there is a plugin available by vrongmeal but I was wondering if there any other methods?
Yep, the git plugin is probably the best option for keeping it up to date automatically without user interaction.
You’ll probably want to also make use of the templates directive which will let you render the markdown on the fly with Caddy, and wrap a layout around the markdown content.
Would it use the same format as the v1 git plugin? I took a look at the example for v2 and it seems somewhat different.
This will be my first time using it so am treading cautiously, indeed it’s my first time using Caddy at all!
Is there an example file I could look at other than the one on the authors site? I did do a search but couldn’t find much in the way of people showcasing this.
No, it’s a complete rewrite from the v1 plugin. Also, unfortunately it doesn’t have Caddyfile support yet, but that should come soon enough. All the docs for it are in the README.
You can write your config with Caddyfile syntax first, then use the caddy adapt command to convert it to JSON and make your modifications to configure caddygit for now.
2020/06/12 15:36:11.232 INFO using provided configuration {"config_file": "caddy.json", "config_adapter": ""}
2020/06/12 15:36:11.232 INFO admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["[::1]:2019", "127.0.0.1:2019", "localhost:2019"]}
2020/06/12 15:36:11.232 INFO git starting module
2020/06/12 15:36:11.233 INFO autosaved config {"file": "/root/.config/caddy/autosave.json"}
2020/06/12 15:36:11.233 INFO serving initial configuration
Successfully started Caddy (pid=636) - Caddy is running in the background
root@docs:/# 2020/06/12 15:36:11.233 INFO git setting up repository {"path": "/system.wiki"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xc0 pc=0x73e227]
goroutine 17 [running]:
os/exec.(*Cmd).String(0x0, 0x0, 0x15)
os/exec/exec.go:203 +0x37
github.com/vrongmeal/caddygit/client.(*Command).String(0xc00020b708, 0x0, 0x17b4177)
github.com/vrongmeal/caddygit@v0.0.0-20200504202456-aefa223497b8/client/commands.go:77 +0x39
github.com/vrongmeal/caddygit/client.(*Commander).Run(0xc0001e1b90, 0x1af3760, 0xc000096d00, 0x0, 0x0)
github.com/vrongmeal/caddygit@v0.0.0-20200504202456-aefa223497b8/client/commands.go:23 +0x82
github.com/vrongmeal/caddygit/client.(*Client).Start(0xc00015a2c0, 0x1af3760, 0xc000096d00, 0xc0001c9200, 0xc0004791a0)
github.com/vrongmeal/caddygit@v0.0.0-20200504202456-aefa223497b8/client/client.go:188 +0x56b
created by github.com/vrongmeal/caddygit.(*App).StartClients
github.com/vrongmeal/caddygit@v0.0.0-20200504202456-aefa223497b8/caddygit.go:107 +0x70
Not sure if those errors are normal or not as this is early release software (probably me doing something wrong! )
I am running Caddy on a separate server to where the Gitlab instance is installed. It has an internal name of “docs.caminfo.local”. How do I get it to publish to here? Just http://docs.caminfo.local would be fine as it’s an internal only site. That hostname is resolvable by internal DNS.
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.
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?
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.
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: