Crossplatform running and docs

This commit is contained in:
2026-01-08 16:27:24 +01:00
parent 910420b5d9
commit 5aefef465f
3 changed files with 59 additions and 4 deletions

View File

@@ -10,6 +10,13 @@ IMGFLOAT_ASSETS_PATH ?= ./assets
IMGFLOAT_PREVIEWS_PATH ?= ./previews IMGFLOAT_PREVIEWS_PATH ?= ./previews
SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE ?= 10MB SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE ?= 10MB
SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE ?= 10MB SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE ?= 10MB
WATCHDIR = ./src/main
ELECTRON := $(shell \
if [ -f /etc/os-release ] && grep -q '^ID=nixos' /etc/os-release; then \
echo electron; \
else \
echo "npx electron"; \
fi)
RUNTIME_ENV = IMGFLOAT_ASSETS_PATH=$(IMGFLOAT_ASSETS_PATH) \ RUNTIME_ENV = IMGFLOAT_ASSETS_PATH=$(IMGFLOAT_ASSETS_PATH) \
IMGFLOAT_PREVIEWS_PATH=$(IMGFLOAT_PREVIEWS_PATH) \ IMGFLOAT_PREVIEWS_PATH=$(IMGFLOAT_PREVIEWS_PATH) \
IMGFLOAT_GITHUB_OWNER=$(IMGFLOAT_GITHUB_OWNER) \ IMGFLOAT_GITHUB_OWNER=$(IMGFLOAT_GITHUB_OWNER) \
@@ -17,7 +24,6 @@ RUNTIME_ENV = IMGFLOAT_ASSETS_PATH=$(IMGFLOAT_ASSETS_PATH) \
IMGFLOAT_DB_PATH=$(IMGFLOAT_DB_PATH) \ IMGFLOAT_DB_PATH=$(IMGFLOAT_DB_PATH) \
SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE=$(SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE) \ SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE=$(SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE) \
SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE=$(SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE) SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE=$(SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE)
WATCHDIR = ./src/main
node_modules: package-lock.json node_modules: package-lock.json
npm install npm install
@@ -43,9 +49,13 @@ test:
package: package:
mvn clean package mvn clean package
.PHONY: run-client
run-client:
IMGFLOAT_CHANNELS_URL=http://localhost:8080/channels $(ELECTRON) ./src/main/node/app.js
.PHONY: runx .PHONY: runx
runx: run-client-x:
IMGFLOAT_CHANNELS_URL=http://localhost:8080/channels ./src/main/shell/run-electron-app-in-xorg IMGFLOAT_CHANNELS_URL=http://localhost:8080/channels ./src/main/shell/run-electron-app-in-xorg $(ELECTRON)
.PHONY: fix .PHONY: fix
fix: node_modules fix: node_modules

View File

@@ -20,6 +20,8 @@ Visit [imgfloat.kruhlmann.dev](https://imgfloat.kruhlmann.dev) once your streame
## Running locally ## Running locally
### Environment
Define the following required environment variables: Define the following required environment variables:
| Variable | Description | Example Value | | Variable | Description | Example Value |
@@ -54,3 +56,45 @@ IMGFLOAT_GITHUB_OWNER=...
IMGFLOAT_GITHUB_REPO=... IMGFLOAT_GITHUB_REPO=...
IMGFLOAT_INITIAL_TWITCH_USERNAME_SYSADMIN=... IMGFLOAT_INITIAL_TWITCH_USERNAME_SYSADMIN=...
``` ```
### Build and run
To run the application:
```sh
$ make run
...
... : Tomcat started on port 8080 (http) with context path ''
```
If you want live compilation run the `watch` command in a separate terminal. Note that this doesn't automatically reload the browser; this has to be done manually.
```sh
$ make watch
...
[INFO] BUILD SUCCESS
```
This automatically re-compiles the project when source files change. `entr` is required for this to work.
### Running the electron client
There are two methods of running the electron app during development.
#### Running in the current X server
```sh
$ make run-client
...
^C
```
#### Running in a sandboxed X server
This method spawns an Xorg server with `Xephyr` and `openbox` to ensure a floating window manager, which will more accurately reflect the common user environment. Killing either the Xephyr or electron process shuts both down.
```sh
$ make run-client-x
...
^C
```

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
set -eu set -eu
ELECTRON="$1"
APP_ENTRY="src/main/node/app.js" APP_ENTRY="src/main/node/app.js"
SCREEN="1280x800" SCREEN="1280x800"
@@ -33,7 +34,7 @@ OPENBOX_PID=$!
sleep 0.5 sleep 0.5
DISPLAY=":$DISP" electron "$APP_ENTRY" & DISPLAY=":$DISP" "${ELECTRON}" "$APP_ENTRY" &
ELECTRON_PID=$! ELECTRON_PID=$!
DISPLAY=":$DISP" xsetroot -solid "#009999" DISPLAY=":$DISP" xsetroot -solid "#009999"