Bug 246623 - www/caddy - update to 2.0.0
Summary: www/caddy - update to 2.0.0
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-ports-bugs mailing list
URL: https://caddyserver.com/v2
Keywords: buildisok
Depends on:
Blocks:
 
Reported: 2020-05-21 09:05 UTC by Daniel Tihanyi
Modified: 2020-05-27 18:26 UTC (History)
5 users (show)

See Also:
bugzilla: maintainer-feedback? (fabian.freyer)


Attachments
Caddy diff (31.37 KB, patch)
2020-05-21 09:05 UTC, Daniel Tihanyi
no flags Details | Diff
Caddy 2 diff (31.31 KB, patch)
2020-05-21 09:08 UTC, Daniel Tihanyi
no flags Details | Diff
Caddy 2 diff (31.37 KB, patch)
2020-05-22 05:27 UTC, Daniel Tihanyi
no flags Details | Diff
caddy2-diff (32.79 KB, patch)
2020-05-27 17:52 UTC, Daniel Tihanyi
no flags Details | Diff
caddy2-diff (33.89 KB, patch)
2020-05-27 18:22 UTC, Daniel Tihanyi
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tihanyi 2020-05-21 09:05:21 UTC
Created attachment 214710 [details]
Caddy diff

caddy 2.0.0 has been released and it obsoleted caddy 1.x.
There is no official list of changes, they created a site highlighting the changes: https://caddyserver.com/v2

The official rc script from version 1.x is gone, I wrote a new one using caddy's own commands. At this time caddy 2.0 cannot create a pid file, however it will be implemented in 2.1 (https://github.com/caddyserver/caddy/issues/3235 ). I will update the rc as well once 2.1 is released to install the pid file.

I am also willing to take over maintainership for this port.
Comment 1 Daniel Tihanyi 2020-05-21 09:08:02 UTC
Created attachment 214711 [details]
Caddy 2 diff

Updated diff, I missed the Makefile header.
Comment 2 Automation User 2020-05-21 09:27:45 UTC
Build info is available at https://gitlab.com/swills/freebsd-ports/pipelines/148251505
Comment 3 Daniel Tihanyi 2020-05-22 05:27:41 UTC
Created attachment 214742 [details]
Caddy 2 diff

Updated diff, I removed the "created by" line as I needed to rewrite the Makefile. I left the maintainer as it is for now.
Comment 4 Basil Hendroff 2020-05-22 06:56:17 UTC
(In reply to Daniel Tihanyi from comment #0)

Hi Daniel,

For my own understanding, how important is it that Caddy V2 create a PID file, or require LOGIN and DAEMON? I haven't found these to be showstoppers in getting Caddy V2 working in the rc.d framework. This thread also seems to suggest that a PID file in not entirely necessary https://forums.freebsd.org/threads/rc-d-script-to-start-a-sh-script.63178/ 

I've also independently worked on an rc script. Details can be found at https://github.com/basilhendroff/freenas-iocage-caddyv2. What's reassuring is that we have got to similar points quite independently. 

A couple of comments on your rc script.
 
1. I do like elements of what you've done especially around command_args and command flags.

command_args="${caddy_flags} -config ${caddy_config}"

I wonder if the order should be switched though, or whether it matters? i.e. 

command_args="--config ${caddy_config} ${caddy_flags}"

Why? For instance, it may facilitate implementing a 'quiet mode'. As you will be aware, the Caddy start and reload commands generate quite a lot of output. In its simplest form, this can be prevented by setting caddy_flags="> /dev/null 2>&1" in /etc/rc.conf.

2. The script I came up with is very similar to yours, but deviates slightly in a couple of places. You might like to consider these deviations.

2.1 Kudos on the start, validate and reloads methods. However, it's not exactly clear to me why you've implemented a separate stop method. The built-in method appears to work well.

2.2 The location of the Caddyfile and Caddy executable, I've set up as configurable script parameters caddy_config_path and cadd_bin_path. For instance, I think in the V1 rc script, the default Caddyfile location was /usr/local/www/Caddyfile. This may be important for some users migrating from V1 to V2.

Thank you for offering to maintain the port. This was raised as recently as a few hours ago by the Caddy dev in this Caddy forum post https://caddy.community/t/caddy-version-1-end-of-life-date/7835/26
Comment 5 dan 2020-05-22 11:22:34 UTC
A couple of questions:

1.  Given the complete lack of backward compatibility, might it be better to have a separate port for Caddy v2 (called, perhaps, "caddy2")?

2.  Is it possible to build Caddy's plugins with this port?  I'm most interested in the DNS validation plugins, but I'd suppose any others would work the same way.
Comment 6 Daniel Tihanyi 2020-05-23 14:49:53 UTC
Thank you for the feedback!
@Basil: As far as I've read here: https://www.freebsd.org/doc/en_US.ISO8859-1/articles/rc-scripting/article.html pid file creation is desired, but I don't think it's absolutely necessary. I just left out the workarounds with install or daemon because I also think that it's not absolutely necessary for a service to run, but it's nice. I will modify the rc script once 2.1 is released.
Also from the same document it's nice to wait until LOGIN. NETWORKING also sounds logical. Regarding daemon, I'm not entirely sure if it is needed there, I was loooking at the rc.d script of www/h2o and it was listed there.
Sure I guess reordering makes sense. I've created a stop method because it has one, I'm not sure which one is "better". I tough maybe there is something extra that caddy's own stop procedure does.
@Dan: I guess we can create a separate www/caddy2 port. I'm not sure if anything is needed from my site, I am happy to add the svn diff against and empty caddy2 port. Regarding plugins, I'm not sure how can you do that without using xcaddy. I'm open to see suggestions how the Makefule should look live to use xcaddy and also maybe some Options to build it with DNS or other plugins.
Comment 7 Basil Hendroff 2020-05-24 12:12:38 UTC
(In reply to Daniel Tihanyi from comment #6)


Hi Daniel,
Thank you for considering the additional feedback from Dan and myself. I would also encourage you to visit and continue to monitor the Caddy forum post https://caddy.community/t/caddy-version-1-end-of-life-date/7835/11 as there has been some new feedback from the Caddy team, and, it is likely the 
Caddy team will use this as the vehicle for further feedback.

There are two key stakeholder groups here - Representing and driving it from the FreeBSD side, at this stage, are you, Dan and me; From the Caddy side, it is Matt Holt and his team. Where possible, we want to try and accommodate the interests of both groups. I'm going to try to impartially, but critically, speak to this in the points below.

1. pidfile, DAEMON, etc.

Like you, I'm scratching my head wondering about the significance of some elements. Maybe there's a gap in my knowledge; maybe it's a FreeBSD compliance thing. If it's the latter, what bothers me is that we add in superfluous elements that appear to add no real value to running Caddy in the FreeBSD rd.c framework. The issue that we create is that, down the track, those following in our footsteps, lose sight of what's relevant and what's not.

Thank you for considering my suggestion about command_args reordering. I still think this is a good idea, however, based on feedback from the Caddy team, I now withdraw my comments about a 'quiet mode'.  

2. The location of the Caddy binary and Caddyfile.

From a FreeBSD perspective, if you are to maintain backward compatibility with the V1 package, the Caddy binary should be located in /usr/local/bin/caddy and for the Caddyfile it is /usr/local/www/Caddyfile. From a Caddy perspective, the preferred locations for V2 are /usr/bin/caddy and /etc/caddy/Caddyfile. 

The way to accommodate both groups is to include configurable script parameters in the rc script for both the binary and Caddyfile. The tough decision for you to make will be to decide which set of defaults to use. I think the question for you to consider in this will be 'Which stakeholder group will benefit most from the defaults?'.

3. Caddy2

I can understand why Dan has raised this. Matt has some concerns with the approach though. I think what's important from a FreeBSD perspective is that both V1 and V2 continue to be available for the foreseeable future. Given the lack of backward compatibility, this is not an unreasonable request. Is it possible to accommodate both Dan and Matt's concerns? I don't have enough understanding of the ports framework to make any suggestions around this, but I guess, ideally, caddy should default to the latest version, but V1 should be selectable via some switch.
Comment 8 Basil Hendroff 2020-05-24 19:32:21 UTC
Hi Daniel,

I'd like to make a further point on the location of the Caddy binary and Caddyfile. While from a Caddy perspective, the preferred locations for V2 are /usr/bin/caddy and /etc/caddy/Caddyfile, this doesn't take into account that FreeBSD has a fairly strict filesystem hierarchy, such that (as I understand it) anything that isn't part of a base FreeBSD installation lives somewhere under /usr/local/. More information is available about this at https://www.freebsd.org/doc/handbook/dirstructure.html and man hier https://www.freebsd.org/cgi/man.cgi?query=hier&sektion=7&manpath=freebsd-release-ports

Therefore, to accommodate defaults from a Caddy V2 perspective within the FreeBSD ports framework, the transformation of those locations would likely be:

/usr/bin/caddy -> /usr/local/bin/caddy
/etc/caddy/Caddyfile -> /usr/local/etc/Caddyfile
Comment 9 Daniel Tihanyi 2020-05-27 17:52:36 UTC
Created attachment 214926 [details]
caddy2-diff

I updated the port, now we install a sample configuration file to /usr/local/etc/caddy/Caddyfile.sample. I also updated the description, added an install message and reordered the rc script to make caddy_options the argument. I also corrected couple of errors I found in the Makefile and rc script.
portlint now says it"s fine, also passes poudriere tests.
Comment 10 Daniel Tihanyi 2020-05-27 18:22:30 UTC
Created attachment 214927 [details]
caddy2-diff

I added now the sample configuration file which was missing before.
Comment 11 Daniel Tihanyi 2020-05-27 18:26:46 UTC
@Basil: with this Makefile, caddy will install to /usr/local/bin/caddy. This is the standard location on FreeBSD. I'm also creating a sample Caddyfile in /usr/local/etc/caddy/Caddyfile, but the user is free to put the config anywhere and point the rc script also there.