sourcegraph/dev/Caddyfile-sveltekit
Felix Kling 1c729823d5
refactor(svelte): Improve integration with sg (#64333)
There currently isn't a 'one step' way to start a local Sourcegraph
instance with the SvelteKit app.

This commit adds `sg start enterprise-sveltekit` to fix that.

The changes in https://github.com/sourcegraph/sourcegraph/pull/64272
allow us to run the vite dev server in front of the Sourcegraph
instance, instead of building the assets and having them served by
frontend.
This gives us the benefit of hot module reloading and in general seems
to be a less fragile approach.

It's basically the same what we do with the React app in development
mode.

## Test plan

`sg start enterprise-sveltekit` starts the vite dev server as well as
the sourcegraph instance. Navigating to
`https://sourcegraph.test:3443/search` opens the Svelte app (when
enabled and logged in). Making a change in a source file updates the web
page immediately.

`sg start web-sveltekit-standalone` still works
2024-08-08 11:39:26 +02:00

27 lines
693 B
Caddyfile

{
http_port 3081
auto_https disable_redirects
}
# A bit of monstrosity, since we need to reverse proxy via the vite dev server which then
# reverse proxies to the esbuild dev server which reverse proxies to us on HTTP.
#
# Caddy (tls :3443) -> vite dev server (:5173) -> esbuild dev server (:3080) -> Caddy (:3081) -> sourcegraph-frontend (:3082)
{$SOURCEGRAPH_HTTPS_DOMAIN}:{$SOURCEGRAPH_HTTPS_PORT} {
tls internal
reverse_proxy localhost:5173 {
lb_try_duration 60s
}
}
# Caddy (:3081) -> sourcegraph-frontend (:3082)
:3081 {
reverse_proxy 127.0.0.1:3082
}
# Caddy (:3083) -> Cody Gateway (:9992)
{$SOURCEGRAPH_HTTPS_DOMAIN}:3083 {
tls internal
reverse_proxy 127.0.0.1:9992
}