docs: improve contribution documentation (#5540)

pull/5541/head
Henrique Dias 2025-11-13 17:16:50 +01:00 committed by GitHub
parent 0bab2aba9e
commit 8fcfb502ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 62 additions and 46 deletions

View File

@ -15,11 +15,23 @@ We encourage you to use git to manage your fork. To clone the main repository, j
git clone https://github.com/filebrowser/filebrowser
```
We use [Taskfile](https://taskfile.dev/) to manage the different processes (building, releasing, etc) automatically.
## Build
You can fully build the project in order to produce a binary by running:
```bash
task build
```
## Development
For development, there are a few things to have in mind.
### Frontend
We are using [Node.js](https://nodejs.org/en/) on the frontend to manage the build process. The steps to build it are:
We use [Node.js](https://nodejs.org/en/) on the frontend to manage the build process. Prepare the frontend environment:
```bash
# From the root of the repo, go to frontend/
@ -27,37 +39,62 @@ cd frontend
# Install the dependencies
pnpm install
```
# Build the frontend
If you just want to develop the backend, you can create a static build of the frontend:
```bash
pnpm run build
```
This will install the dependencies and build the frontend so you can then embed it into the Go app. Although, if you want to play with it, you'll get bored of building it after every change you do. So, you can run the command below to watch for changes:
If you want to develop the frontend, start a development server which watches for changes:
```bash
pnpm run dev
```
Please note that you need to access File Browser's interface through the development server of the frontend.
### Backend
First of all, you need to download the required dependencies. We are using the built-in `go mod` tool for dependency management. To get the modules, run:
First prepare the backend environment by downloading all required dependencies:
```bash
go mod download
```
The magic of File Browser is that the static assets are bundled into the final binary. For that, we use [Go embed.FS](https://golang.org/pkg/embed/). The files from `frontend/dist` will be embedded during the build process.
To build File Browser is just like any other Go program:
You can now build or run File Browser as any other Go project:
```bash
# Build
go build
# Run
go run .
```
To create a development build use the "dev" tag, this way the content inside the frontend folder will not be embedded in the binary but will be reloaded at every change:
## Documentation
We rely on Docker to abstract all the dependencies required for building the documentation.
To build the documentation to `www/public`:
```bash
go build -tags dev
task docs
```
To start a local server on port `8000` to view the built documentation:
```bash
task docs-serve
```
## Release
To make a release, just run:
```bash
task release
```
## Translations

View File

@ -33,17 +33,24 @@ tasks:
- task: build-frontend
- task: build-backend
release:
desc: Create a new release
release-make:
internal: true
prompt: Do you wish to proceed?
cmds:
- pnpm dlx commit-and-tag-version -s
release-dry-run:
desc: Perform a dry run of the release
internal: true
cmds:
- pnpm dlx commit-and-tag-version -dry-run --skip
- pnpm dlx commit-and-tag-version --dry-run --skip
make-docs-image:
release:
desc: Create a new release
cmds:
- task: release-dry-run
- task: release-make
docs-image-make:
internal: true
cmds:
- docker build -f www/Dockerfile --progress=plain -t filebrowser.site www
@ -52,11 +59,11 @@ tasks:
desc: Generate documentation
cmds:
- rm -rf www/public
- task: make-docs-image
- task: docs-image-make
- docker run --rm {{.SITE_DOCKER_FLAGS}} filebrowser.site build -d "public"
docs-serve:
desc: Serve documentation
cmds:
- task: make-docs-image
- task: docs-image-make
- docker run --rm -it -p 8000:8000 {{.SITE_DOCKER_FLAGS}} filebrowser.site

View File

@ -1,14 +0,0 @@
//go:build dev
package frontend
import (
"io/fs"
"os"
)
var assets fs.FS = os.DirFS("frontend")
func Assets() fs.FS {
return assets
}

View File

@ -1,14 +0,0 @@
//go:build dev
package http
// global headers to append to every response
// cross-origin headers are necessary to be able to
// access them from a different URL during development
var globalHeaders = map[string]string{
"Cache-Control": "no-cache, no-store, must-revalidate",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*",
"Access-Control-Allow-Methods": "*",
"Access-Control-Allow-Credentials": "true",
}