x/pkgsite: local setup - tracking issue #40371
Comments
Hello @julieqiu If I can add color to the pain points of running locally, having to start a proxy isn't too much trouble, but the constraint of requiring https is a bigger barrier:
What do you think about relaxing this constraint? |
Change https://golang.org/cl/245639 mentions this issue: |
Rather than validating the URL in proxy.New, assume that the URL that is passed in is valid. This allows users to connect to a proxy running locally in direct proxy mode. For golang/go#40371 Change-Id: Id51cb27148987e58d214cef1c805b26b5138a6de Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245639 Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
@achille-roussel - done! Thanks for the feedback. |
To run Executables in docker containers can more easily publish their services on the host's networking interface if bound to https://github.com/golang/pkgsite/blob/ef183200d192b20102bb1246a86ae11de2d0738e/cmd/frontend/main.go#L170 to use a variable that is assigned by a flag instead of the |
We had to solve for this as well in the fork we maintain at https://github.com/segmentio/pkgsite: diff --git a/cmd/frontend/main.go b/cmd/frontend/main.go
index 5773d8e..e81022b 100644
--- a/cmd/frontend/main.go
+++ b/cmd/frontend/main.go
@@ -42,6 +42,7 @@ var (
"for direct proxy mode and frontend fetches")
directProxy = flag.Bool("direct_proxy", false, "if set to true, uses the module proxy referred to by this URL "+
"as a direct backend, bypassing the database")
+ httpAddr = flag.String("http", "localhost:8080", "address to listen for incoming requests on")
)
func main() {
@@ -167,7 +168,7 @@ func main() {
middleware.Timeout(54*time.Second),
middleware.Experiment(experimenter),
)
- addr := cfg.HostAddr("localhost:8080")
+ addr := cfg.HostAddr(*httpAddr)
log.Infof(ctx, "Listening on addr %s", addr)
log.Fatal(ctx, http.ListenAndServe(addr, mw(router)))
} Taking a closer look at the way the configuration is setup, it appears that if the // HostAddr returns the network on which to serve the primary HTTP service.
func (c *Config) HostAddr(dflt string) string {
if c.Port != "" {
return fmt.Sprintf(":%s", c.Port)
}
return dflt
} |
Change https://golang.org/cl/260779 mentions this issue: |
Create -local and -gopath_mode flags to enable using a local datasource and loading local modules to memory. Updates golang/go#40371 Fixes golang/go#40159 Change-Id: I36941adde9c6b186d95b5792051854ac3d1a2ac8 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/260779 Run-TryBot: Jonathan Amsterdam <jba@google.com> Trust: Jonathan Amsterdam <jba@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
Functionality for running the pkgsite frontend locally is moved from cmd/frontend to cmd/pkgsite, since cmd/frontend is currently overloaded with flag options and running locally does not need all the dependencies for running cmd/frontend. Additional functionality will be added to cmd/pkgsite in future CLs. For golang/go#40371 Change-Id: I4230aa9539c94e01a68eda33cc6492ae377debff Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/290134 Reviewed-by: Jamal Carvalho <jamal@golang.org> Trust: Julie Qiu <julie@golang.org>
Change https://golang.org/cl/290134 mentions this issue: |
Change https://golang.org/cl/290135 mentions this issue: |
A -http flag is added which allows the user to specify which HTTP addr to listen in on. For golang/go#40371 Change-Id: Ibfe32281e9a821444df5e538fd7057f39318c546 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/290135 Reviewed-by: Jonathan Amsterdam <jba@google.com> Trust: Julie Qiu <julie@golang.org>
Today, users can run pkgsite locally without setting up a local database by running:
go run cmd/frontend/main.go -direct_proxy -proxy_url=<your proxy URL>
See flags in
cmd/frontend/main.go
, and doc/frontend.md for docs.Doing so allows users to view the package documentation, overview, imports, and licenses tabs. Search and other tabs on the package page are not supported in direct proxy mode.
However, there are cases when a user might want to run pkgsite on their local machine, and be able to view a private repository that is not available via a proxy.
Issues related to this topic:
This is an umbrella issue to discuss what features are needed for this to happen, so please comment on your use cases below. For discussions about hosting a private instance of pkgsite, including your own internal proxy, see #39827.
The text was updated successfully, but these errors were encountered: