Add configurable base path#947
Open
pascal-cm wants to merge 1 commit intolouislam:masterfrom
Open
Conversation
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Synopsis
Adds capabilities to Dockge for deployments under a custom base path (e.g.
http://localhost:5001/dockge/).Rationale
Currently Dockge lacks the ability to be deployed under a base path other than the default
/, which is a common requirement for services running behind a reverse proxy. This PR modifies the frontend, backend and the Docker Compose manifest to allow for Dockge to run under any path.The base path may be set during deployment – no frontend or image re-building required.
Works in local development via
npm run dev, too.Changed files
Most of the magic happens by setting Vite's base option and exposing it as
<base href="%BASE_URL%">. While the build time value of./solves some of the requirements, the remaining code is to change the relative path to the value ofDOCKGE_BASE_PATHat runtime.The code around it for the server part is about mutating
index.hmtl(inmutateIndexHTML()) to include a dynamic<base href="..." />, while on client side, thebasetag'shrefvalue is used for URL construction (socket = io(url, { path: new URL("socket.io", document.baseURI).pathname });).Project
node-html-parser(MIT licensed, dependencies MIT and BSD-2-Clause licensed)Frontend
basetagbaseoptionobjectassetsbasetagBackend
basePathoptionindex.htmlwithbasePathDocker
DOCKGE_BASE_PATHenv varTesting
As Dockge seemingly does not have any automated tests suites, all tests were conducted manually.
This script may be used as a quick way for assessment:
Run the script without configuring
DOCKGE_BASE_PATH:Dockge should be running under
http://localhost:5001/.Now configure a base path by setting
DOCKGE_BASE_PATHper CLI :Dockge should be now be running under
http://localhost:5001/dockge/.If you prefer to keep settings in a
.envfile, be aware these are also picked up bynpm run dev:frontendandnpm run dev:backend.Reverse Proxy Example
When running behind a reverse proxy, both the base path with and without a trailing slash should be proxied. E.g, this snippet configures Caddy to act as a reverse proxy when running Dockge with
DOCKGE_BASE_PATH=/dockge.Note that the above example is just for illustration and may require addition configuration, such as disabling buffers, etc.
Notes
/*(for example/admin/dockge/*todockge:5001) #903Type of change
Please delete any options that are not relevant.
Checklist
(including JSDoc for methods)