Reactserv
HTTP server to serve React static files from memory. You can also set the root URL.
Features
- Reads the static React files from disk and serves them from memory
- Modify in-memory files with the
ROOT_URL
set, so using a reverse proxy is easier - Reloads files in memory on any file change (works on all platforms, and obviously Linux/Docker)
- Compatible with
amd64
,386
,arm64
,arm32v7
,arm32v6
,ppc64le
ands390x
CPU architectures - Docker image tags and sizes
Setup
-
Place your compiled React code in a directory, for example
/yourpath/react
. -
Use the following command:
docker run -d -p 8000:8000/tcp -v /yourpath/react:/srv:ro qmcgaw/reactserv
You can also use docker-compose.yml with:
docker-compose up -d
-
You can update the image with
docker pull qmcgaw/reactserv:latest
or use one of tags available
Environment variables
Environment variable | Default | Possible values | Description |
---|---|---|---|
LOG_ENCODING |
console |
json , console |
Logging format |
LOG_LEVEL |
info |
debug , info , warning , error |
Logging level |
LISTENING_PORT |
8000 |
Integer between 1 and 65535 |
Internal listening TCP port |
ROOT_URL |
/ |
URL path string | URL path, used if behind a reverse proxy |
ROOT_DIR |
srv |
Absolute or relative file path | Root filesystem path to read files from |
TZ |
America/Montreal |
string | Timezone |
Development
-
Setup your environment
Using VSCode and Docker (easier)
- Install Docker
- On Windows, share a drive with Docker Desktop and have the project on that partition
- On OSX, share your project directory with Docker Desktop
- With Visual Studio Code, install the remote containers extension
- In Visual Studio Code, press on
F1
and selectRemote-Containers: Open Folder in Container...
- Your dev environment is ready to go!... and it's running in a container 👍 So you can discard it and update it easily!
Locally
-
Install Go dependencies with
go mod download
-
Install golangci-lint
-
You might want to use an editor such as Visual Studio Code with the Go extension. Working settings are already in .vscode/settings.json.
- Install Docker
-
Commands available:
# Build the binary go build cmd/app/main.go # Test the code go test ./... # Lint the code golangci-lint run # Build the Docker image docker build -t qmcgaw/reactserv .
-
See Contributing for more information on how to contribute to this repository.
TODOs
- Add default favicon.ico
- Authentication with OAuth or similar
License
This repository is under an MIT license unless otherwise indicated