Fix empty WebUI static assets directory
This commit is contained in:
parent
6974f54bfd
commit
fb23bd5d26
11 changed files with 27 additions and 19 deletions
2
.github/workflows/build.yaml
vendored
2
.github/workflows/build.yaml
vendored
|
@ -23,7 +23,7 @@ jobs:
|
||||||
|
|
||||||
- name: Build webui
|
- name: Build webui
|
||||||
run: |
|
run: |
|
||||||
make generate-webui
|
make clean-webui generate-webui
|
||||||
tar czvf webui.tar.gz ./webui/static/
|
tar czvf webui.tar.gz ./webui/static/
|
||||||
|
|
||||||
- name: Artifact webui
|
- name: Artifact webui
|
||||||
|
|
2
.github/workflows/test-unit.yaml
vendored
2
.github/workflows/test-unit.yaml
vendored
|
@ -40,7 +40,7 @@ jobs:
|
||||||
restore-keys: ${{ runner.os }}-test-unit-go-
|
restore-keys: ${{ runner.os }}-test-unit-go-
|
||||||
|
|
||||||
- name: Avoid generating webui
|
- name: Avoid generating webui
|
||||||
run: mkdir -p webui/static && touch webui/static/index.html
|
run: touch webui/static/index.html
|
||||||
|
|
||||||
- name: Tests
|
- name: Tests
|
||||||
run: make test-unit
|
run: make test-unit
|
||||||
|
|
2
.github/workflows/validate.yaml
vendored
2
.github/workflows/validate.yaml
vendored
|
@ -48,7 +48,7 @@ jobs:
|
||||||
run: curl -sfL https://raw.githubusercontent.com/client9/misspell/master/install-misspell.sh | sh -s -- -b $(go env GOPATH)/bin ${MISSSPELL_VERSION}
|
run: curl -sfL https://raw.githubusercontent.com/client9/misspell/master/install-misspell.sh | sh -s -- -b $(go env GOPATH)/bin ${MISSSPELL_VERSION}
|
||||||
|
|
||||||
- name: Avoid generating webui
|
- name: Avoid generating webui
|
||||||
run: mkdir -p webui/static && touch webui/static/index.html
|
run: touch webui/static/index.html
|
||||||
|
|
||||||
- name: Validate
|
- name: Validate
|
||||||
run: make validate
|
run: make validate
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,7 +5,6 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/dist
|
/dist
|
||||||
/webui/.tmp/
|
/webui/.tmp/
|
||||||
/webui/static/
|
|
||||||
/site/
|
/site/
|
||||||
/docs/site/
|
/docs/site/
|
||||||
/autogen/
|
/autogen/
|
||||||
|
|
|
@ -40,7 +40,7 @@ blocks:
|
||||||
- name: Test Integration
|
- name: Test Integration
|
||||||
commands:
|
commands:
|
||||||
- make pull-images
|
- make pull-images
|
||||||
- mkdir -p webui/static && touch webui/static/index.html # Avoid generating webui
|
- touch webui/static/index.html # Avoid generating webui
|
||||||
- PRE_TARGET="" make binary
|
- PRE_TARGET="" make binary
|
||||||
- make test-integration
|
- make test-integration
|
||||||
- df -h
|
- df -h
|
||||||
|
|
13
Makefile
13
Makefile
|
@ -58,14 +58,18 @@ dist:
|
||||||
build-webui-image:
|
build-webui-image:
|
||||||
docker build -t traefik-webui --build-arg ARG_PLATFORM_URL=$(PLATFORM_URL) -f webui/Dockerfile webui
|
docker build -t traefik-webui --build-arg ARG_PLATFORM_URL=$(PLATFORM_URL) -f webui/Dockerfile webui
|
||||||
|
|
||||||
|
## Clean WebUI static generated assets
|
||||||
|
clean-webui:
|
||||||
|
rm -r webui/static
|
||||||
|
mkdir -p webui/static
|
||||||
|
echo 'For more information show `webui/readme.md`' > webui/static/DONT-EDIT-FILES-IN-THIS-DIRECTORY.md
|
||||||
|
|
||||||
## Generate WebUI
|
## Generate WebUI
|
||||||
generate-webui:
|
generate-webui:
|
||||||
if [ ! -d "webui/static" ]; then \
|
if [ ! -f "webui/static/index.html" ]; then \
|
||||||
$(MAKE) build-webui-image; \
|
$(MAKE) build-webui-image; \
|
||||||
mkdir -p webui/static; \
|
|
||||||
docker run --rm -v "$$PWD/webui/static":'/src/webui/static' traefik-webui npm run build:nc; \
|
docker run --rm -v "$$PWD/webui/static":'/src/webui/static' traefik-webui npm run build:nc; \
|
||||||
docker run --rm -v "$$PWD/webui/static":'/src/webui/static' traefik-webui chown -R $(shell id -u):$(shell id -g) ./static; \
|
docker run --rm -v "$$PWD/webui/static":'/src/webui/static' traefik-webui chown -R $(shell id -u):$(shell id -g) ./static; \
|
||||||
echo 'For more information show `webui/readme.md`' > $$PWD/webui/static/DONT-EDIT-FILES-IN-THIS-DIRECTORY.md; \
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Build the linux binary
|
## Build the linux binary
|
||||||
|
@ -114,8 +118,7 @@ validate: $(PRE_TARGET)
|
||||||
bash $(CURDIR)/script/validate-shell-script.sh
|
bash $(CURDIR)/script/validate-shell-script.sh
|
||||||
|
|
||||||
## Clean up static directory and build a Docker Traefik image
|
## Clean up static directory and build a Docker Traefik image
|
||||||
build-image: binary
|
build-image: clean-webui binary
|
||||||
rm -rf webui/static
|
|
||||||
docker build -t $(TRAEFIK_IMAGE) .
|
docker build -t $(TRAEFIK_IMAGE) .
|
||||||
|
|
||||||
## Build a Docker Traefik image
|
## Build a Docker Traefik image
|
||||||
|
|
|
@ -102,7 +102,7 @@ Once you've set up your go environment and cloned the source repository, you can
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Generate UI static files
|
# Generate UI static files
|
||||||
rm -rf ./webui/static/; make generate-webui
|
make clean-webui generate-webui
|
||||||
|
|
||||||
# required to merge non-code components into the final binary,
|
# required to merge non-code components into the final binary,
|
||||||
# such as the web dashboard/UI
|
# such as the web dashboard/UI
|
||||||
|
|
4
webui/.gitignore
vendored
4
webui/.gitignore
vendored
|
@ -26,3 +26,7 @@ yarn-error.log*
|
||||||
# local env files
|
# local env files
|
||||||
.env.local
|
.env.local
|
||||||
.env.*.local
|
.env.*.local
|
||||||
|
|
||||||
|
# static assets (ignore all except the DO NOT EDIT file)
|
||||||
|
static/*
|
||||||
|
!static/DONT-EDIT-FILES-IN-THIS-DIRECTORY.md
|
||||||
|
|
|
@ -5,6 +5,7 @@ const folder = process.argv[2]
|
||||||
async function execute () {
|
async function execute () {
|
||||||
try {
|
try {
|
||||||
await fs.emptyDir('./static')
|
await fs.emptyDir('./static')
|
||||||
|
await fs.outputFile('./static/DONT-EDIT-FILES-IN-THIS-DIRECTORY.md', 'For more information show `webui/readme.md`')
|
||||||
console.log('Deleted static folder contents!')
|
console.log('Deleted static folder contents!')
|
||||||
await fs.copy(`./dist/${folder}`, './static', { overwrite: true })
|
await fs.copy(`./dist/${folder}`, './static', { overwrite: true })
|
||||||
console.log('Installed new files in static folder!')
|
console.log('Installed new files in static folder!')
|
||||||
|
|
|
@ -14,15 +14,15 @@ Traefik Web UI provide 2 types of information:
|
||||||
Use the make file :
|
Use the make file :
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
make build-image # Generate Docker image
|
make build-image # Generate Docker image.
|
||||||
make generate-webui # Generate static contents in `traefik/webui/static/` folder.
|
make clean-webui generate-webui # Generate static contents in `webui/static/` folder.
|
||||||
```
|
```
|
||||||
|
|
||||||
## How to build (only for frontend developer)
|
## How to build (only for frontend developer)
|
||||||
|
|
||||||
- prerequisite: [Node 12.11+](https://nodejs.org) [Npm](https://www.npmjs.com/)
|
- prerequisite: [Node 12.11+](https://nodejs.org) [Npm](https://www.npmjs.com/)
|
||||||
|
|
||||||
- Go to the `webui` directory
|
- Go to the `webui/` directory
|
||||||
|
|
||||||
- To install dependencies, execute the following commands:
|
- To install dependencies, execute the following commands:
|
||||||
|
|
||||||
|
@ -32,9 +32,9 @@ make generate-webui # Generate static contents in `traefik/webui/static/` fold
|
||||||
|
|
||||||
- `npm run build`
|
- `npm run build`
|
||||||
|
|
||||||
- Static contents are built in the `webui/static` directory
|
- Static contents are built in the `webui/static/` directory
|
||||||
|
|
||||||
**Do not manually change the files in the `webui/static` directory**
|
**Do not manually change the files in the `webui/static/` directory**
|
||||||
|
|
||||||
- The build allows to:
|
- The build allows to:
|
||||||
- optimize all JavaScript
|
- optimize all JavaScript
|
||||||
|
@ -46,10 +46,10 @@ make generate-webui # Generate static contents in `traefik/webui/static/` fold
|
||||||
|
|
||||||
## How to edit (only for frontend developer)
|
## How to edit (only for frontend developer)
|
||||||
|
|
||||||
**Do not manually change the files in the `webui/static` directory**
|
**Do not manually change the files in the `webui/static/` directory**
|
||||||
|
|
||||||
- Go to the `webui` directory
|
- Go to the `webui/` directory
|
||||||
- Edit files in `webui/src`
|
- Edit files in `webui/src/`
|
||||||
- Run in development mode :
|
- Run in development mode :
|
||||||
- `npm run dev`
|
- `npm run dev`
|
||||||
|
|
||||||
|
|
1
webui/static/DONT-EDIT-FILES-IN-THIS-DIRECTORY.md
Normal file
1
webui/static/DONT-EDIT-FILES-IN-THIS-DIRECTORY.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
For more information show `webui/readme.md`
|
Loading…
Reference in a new issue