-
Notifications
You must be signed in to change notification settings - Fork 6
Support for Caddyfile #5
base: main
Are you sure you want to change the base?
Conversation
Hey @rigon |
Wow, that's awesome. Quite the PR! 😄 |
I would be onboard with testing this! I am completely new to Caddy and I need this plugin to replace my existing setup on my Apache server. |
Hey @joeworkman ! Definitely go for it :) |
I am a super n00b with Caddy. How would I take the source to compile it into a custom Caddy build? I have used xcaddy. Although I learned that I need to get it installed on my linux server in order to get a custom build working on that server. I am happy to test if you can help me figure out how to build it. |
You don't need to install it on your Linux server in order to use a custom build there... Where did you learn that? You can compile caddy from any machine, for any machine. Instructions are on this page: https://caddyserver.com/docs/build |
I thought that I would need to use xcaddy to build this on my linux server. When I built a custom build on my Mac earlier today, it would not run on my server (you helped me with that). Its 1am now though. I'll check back in the morning. |
You can do what's called a cross-build on any machine, to build for a different OS/architecture. You just need to set the Assuming your Linux server is x86 (not ARM) and 64-bit, then you would do:
Caddy works on almost every platform combination. There's a list of all the OSes and architectures Go supports here: https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63 |
@@ -102,8 +104,122 @@ $ xcaddy build v2.1.1 \ | |||
} | |||
} | |||
``` | |||
As an handler within a route. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an handler within a route. | |
As a handler within a route. |
"match": [ | ||
{ | ||
"path": [ | ||
"/update" | ||
] | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest moving the matcher to above the handle, where it's more easily noticed. It would make it more apparent that the route is meant for a request to one specific path.
} | ||
``` | ||
|
||
## Caddyfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we also need Caddyfile docs for the global option.
For more control use the following syntax (bear in mind, this options are different from v1): | ||
|
||
git [<matcher>] [<repo>] [<path>] { | ||
repo|url <repo> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I see the value in supporting both repo
and url
at the same time. I think we should just pick one. I don't think the "transition from v1 to v2" matters. Any choice here locks us in forever basically.
Caddy v2 is a complete rewrite compared to Caddy v1 so it's the perfect opportunity for making these kinds of decisions.
branch <branch> | ||
auth_user <username> | ||
auth_secret <password> | ||
single_branch true|false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For boolean options, usually we just make an option with no value that implies "turn on this thing" or "turn off this thing" as the opposite of the default. If the default for single_branch
is false (in JSON), then the option could be named use_single_branch
and drop the true|false
value.
command_after <command> | ||
command_async true|false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Technically more than one command could be run when configured via JSON. There might be a better way to do this to also support multiple commands. Maybe something like:
command_after echo "hello world sync"
command_after echo "hello world async" {
async
}
command_after {
command echo "hello world async long way"
async
}
So each time a command is defined, it would append it to the list, and each one could have the async flag set individually.
For implementation, basically you do a d.RemainingArgs()
to get the command on the same-line, then for nesting := d.Nesting(); d.NextBlock(nesting);
loop to get the options within. Throw an error if a command is defined twice (both via args and the block).
service_type <service type> | ||
service_interval <service interval> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs some explanation, I'm not sure what service types are acceptable as a reader. Is this ssh
vs http
?
I would love to test this today. How can I use xcaddy to build with the version from this PR? |
I think this should work:
|
@mholt Thanks. That got me close. That errored out saying that I needed a local directory. I clone the other repo and an built it like this...
|
I build caddy like this on my local Mac. Server is running Ubuntu.
Here is my Caddyfile
When I try to run caddy, I am getting the following error that the git directive is not registered.
|
Make sure you run the binary you built, not another version. |
I don't know what that is, but it looks like there are two there that look the same. |
That is from the https://caddyserver.com/docs/build#package-support-files-for-custom-builds-for-debianubunturaspbian It does mean that /usr/bin/caddy is pointing to my version that is compile with Cloudflare and Git modules. |
Taking my server out of the mix...
Here is the error that it produces.
|
That's odd. And that's the only Caddy binary on your Mac? I'd feel more sure with a direct path like If that's not it, I'm not sure... never seen that happen before. And you have verified the output of |
It's not my only caddy binary. However, if I run it with |
The
Is this command correct?
|
Ah... no, it's not. After looking closely at the structure of this repo, it turns out the module registration is NOT in the root of this repository. My bad for assuming. The module is registered in That's a bit unusual, so I didn't think to check for it. |
OK. This command works...
But this does not...
I need to reference the local folder since it contains this PR. |
Try:
Edit: never mind...
The |
Got it. Try:
This will underscore-import |
Adapter result (removing cloudflare):
|
That seems to have worked! I never would have guessed to try that. |
Thanks @mohammed90. @joeworkman It's a nuance of how Go modules does replacements, I guess. @vrongmeal Most Caddy modules have their registrations in the root of the repo, that does simplify some things. Please consider that, if you would :) |
So should this module not be using |
I have been trying to figure out the configuration here. I tried to look through the code of the plugin to figure out what is going on. I am completely new to Caddy and Go so it's a bit of overload. Here is what I have so far...
I thought that this may mean that if you go to URL |
I see this error in syslog
It says that there are unstaged changes. However, there aren't any changes in /var/www/aspecthq.com |
@vrongmeal @rigon Can one of you help me with the config? I will be writing a full tutorial on my setup to help others and will be happy to help update the docs. |
I will put my money where my mouth is guys... $100 to the guy/gal who helps me get this working. 😃 |
Run:
It will most likely say something like:
You should handle those unstaged/uncommitted changes. How to handle them depends on your goal, but there's one way here. |
working tree is clean. I have one commit to pull down. I did that on purpose in order to test the plugin.
I am pretty sure that the issue is with the config (or the plugin) |
@joeworkman . I will take it! 👍 What do you want to get done? :-) |
@greenpau I am just trying to get this plugin working. I have my caddy server built with Cloudflare and the code from this PR. This PR adds Caddyfile support for this git plugin. I simply cannot get the plugin to work. I don't know if it's my config or the plugin itself. I am attempting to get the web hook to work. I would expect that when I make a request to the I am all ears... |
@joeworkman , get the $100 ready ;-) will do it in a few hours. |
I am a man of my word! Let's git-r-done... (see what I did there?) LOL |
@joeworkman , please track this issue. |
@joeworkman, I also agreed to it because I love Foundation! 👍 |
Sweet! I may not be able to play around with it until the morning. I'm glad that you love Foundation. Guess what the new website will be running on? 😃 |
So... it looks like you decided to completely write a new plugin from scratch? Huh? |
@francislavoie , for the thing to work I needed to both app and handler. I have a template to do it already. Unfortunately doing it here might take more time than I have. |
@joeworkman , just to be clear. The P.S It took me a while to get Caddyfile format supported. |
Wow, impressive, Paul! Maybe, do you think we could combine the functionality back into this plugin? So there's only 1 git plugin (less confusing, less divergence)? |
@mholt , i tried doing that initially, but after about 30 minutes I realized that would be a 75% rewrite. The other 25% are the git specific functions. The issue here is that caddy app/plugin code is intertwined with the functional (git) code. Thus, to scale and be more readable, it needs to be decoupled. One thing to do something for sport for an hour, another spending days going through such a rewrite. Plus maintainer availability, i.e. reviewing 1000+ lines of code, etc. |
In re:
|
I just wanted to follow up. @greenpau's new plugin is completely working for me now. As promised, I sent him the $100 last night. 💸 😄 |
Happy NY, any update on seeing this merged? |
Hey! I don’t plan on working on this. I encourage you to use the git plugin by @greenpau : https://github.com/greenpau/caddy-git which is more actively maintained. |
No description provided.