Ability to serve static files #1173

Closed
grahammiln wants to merge 2 commits from grahammiln/api:main into main
Contributor

Description

Added the configuration key, service.staticpath, to serve files from the configuration path on root (/).

Serving static files allows the api service to also serve the frontend content. This is a simple option for deploying Vikunja without needing any other servers or proxies.

Running a complete instance becomes:

VIKUNJA_SERVICE_STATICPATH=/path/to/frontend ./vikunja

Where /path/to/frontend is a copy of Vikunja's frontend static files.

Implementation

Providing a path, via the configuration or environment, adds a static file middleware to serve the path's contents from root (/).

By default, the configuration path is empty and Vikunja's existing behaviour is unchanged.

Checklist

  • I added or improved tests
  • I added or improved docs for my feature
    • Swagger (including mage do-the-swag)
    • Error codes
    • New config options (including adding them to config.yml.saml and running mage generate-docs)
# Description Added the configuration key, `service.staticpath`, to serve files from the configuration path on root (/). Serving static files allows the api service to also serve the frontend content. This is a simple option for deploying Vikunja without needing any other servers or proxies. Running a complete instance becomes: VIKUNJA_SERVICE_STATICPATH=/path/to/frontend ./vikunja Where `/path/to/frontend` is a copy of Vikunja's frontend static files. ## Implementation Providing a path, via the configuration or environment, adds a static file middleware to serve the path's contents from root (/). By default, the configuration path is empty and Vikunja's existing behaviour is unchanged. # Checklist * [ ] I added or improved tests * [X] I added or improved docs for my feature * [X] Swagger (including `mage do-the-swag`) * [ ] Error codes * [X] New config options (including adding them to `config.yml.saml` and running `mage generate-docs`)
grahammiln added 2 commits 2022-05-22 12:53:08 +00:00
d998b8099f Add ability to serve static files.
Added a configuration key, `service.staticpath`, to allow the serving
of files from the provided path. By default, the path is empty and
Vikunja's existing behaviour is unchanged.

Providing a path via the configuration, adds a static file middleware to
serve the path's contents from root (/).

Being able to serve static files allows the api service to also serve
the frontend content. This adds a simple option for deploying Vikunja
without needing any other servers or proxies.

Running a complete instance becomes:

VIKUNJA_SERVICE_STATICPATH=/path/to/frontend ./vikunja

Where /path/to/frontend is a copy of Vikunja's frontend static files.

Future improvements could embed a copy of the frontend files via the
fs.FS and embed package. Alternatively a reverse proxy could be offered
using http/httputil's ReverseProxy; this would allow another server to
maintain a default set of frontend files without embedding.
continuous-integration/drone/pr Build is passing Details
b248b98914
Document static path option.
konrad reviewed 2022-05-22 15:16:22 +00:00
@ -9,1 +9,4 @@
## [Unreleased]
* Add static file support for simplified deployment
Owner

Please don't include this - we usually do this at release time.

Please don't include this - we usually do this at release time.
grahammiln marked this conversation as resolved
grahammiln closed this pull request 2022-05-22 15:36:16 +00:00
All checks were successful
continuous-integration/drone/pr Build is passing
Required
Details

Pull request closed

Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: vikunja/vikunja#1173
No description provided.