Skip to content

Commit

Permalink
Refine UI, move to root.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jul 25, 2023
1 parent 1b3ff92 commit 56594ab
Show file tree
Hide file tree
Showing 62 changed files with 60 additions and 63 deletions.
8 changes: 4 additions & 4 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Run the platform backend, or run in GoLand:
Run the platform react ui, or run in WebStorm:

```
(cd platform/ui && npm install && npm start)
(cd ui && npm install && npm start)
```

Access the browser: http://localhost:3000
Expand All @@ -57,21 +57,21 @@ docker run -d --rm -it -p 2022:2022 --name platform -v $(pwd):/usr/local/srs-clo
--add-host redis:127.0.0.1 --env REDIS_HOST=127.0.0.1 --add-host mgmt.srs.local:127.0.0.1 \
--env CLOUD=DOCKER --env MGMT_DOCKER=true --env SRS_DOCKERIZED=true --env NODE_ENV=development \
-p 1935:1935/tcp -p 1985:1985/tcp -p 8080:8080/tcp -p 8000:8000/udp -p 10080:10080/udp \
-w /usr/local/srs-cloud/platform platform-dev bash
-w /usr/local/srs-cloud platform-dev bash
```

> Note: We don't use the `/data` as global storage.
Build platform and UI in docker:

```bash
docker exec -it platform make -j16
docker exec -it platform make -j
```

Run platform in docker:

```bash
docker exec -it platform ./bootstrap
docker exec -it platform ./platform/bootstrap
```

Stop redis and SRS:
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ RUN echo "BUILDPLATFORM: $BUILDPLATFORM, TARGETPLATFORM: $TARGETPLATFORM, TARGET
COPY --from=node /usr/local/bin /usr/local/bin
COPY --from=node /usr/local/lib /usr/local/lib

ADD releases /g/releases
ADD mgmt /g/mgmt
ADD platform /g/platform
ADD ui /g/ui

# Note that we only build the platform without ui, because already build ui for all OS.
# See platform.yml command:
# make ui-build-cn && make ui-build-en
WORKDIR /g/platform
RUN make platform-clean && make platform-build
RUN make ui-clean && make ui-build-cn && make ui-build-en
RUN cd /g/platform/ui && rm -rf js-core node_modules package* public src
WORKDIR /g
RUN make clean && make -j && make install

# http://releases.ubuntu.com/focal/
#FROM ${ARCH}ubuntu:focal AS dist
FROM ${ARCH}ossrs/srs-cloud:focal-1 AS dist

COPY --from=build /g/platform /usr/local/srs-cloud/platform
COPY --from=build /g/platform/platform /usr/local/srs-cloud/platform/platform
COPY --from=build /usr/local/srs-cloud /usr/local/srs-cloud

# Prepare data directory.
RUN mkdir -p /data && \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ COPY --from=srs /usr/local/srs /usr/local/srs
RUN rm -rf /data && ln -sf /usr/local/srs-cloud/platform/containers/data /data

# Setup the work directory to platform.
WORKDIR /usr/local/srs-cloud/platform
WORKDIR /usr/local/srs-cloud
40 changes: 25 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: default build install run uninstall upgrade test npm help clean

SRS_PREFIX=/usr/local/srs-cloud
__REAL_INSTALL=$(DESTDIR)$(SRS_PREFIX)
PREFIX ?= /usr/local/srs-cloud
__REAL_INSTALL = $(DESTDIR)$(PREFIX)

default: build

Expand All @@ -13,29 +13,39 @@ help:
@echo " test Run tests"

build:
cd releases && make
cd platform && make build
make -C platform
make -C ui
make -C releases

clean:
cd releases && make clean
cd platform && make clean
make -C platform clean
make -C ui clean
make -C releases clean

ifeq ($(shell pwd), $(__REAL_INSTALL))
install:
@echo "Install ok for $(__REAL_INSTALL)"
ifeq ($(shell pwd), $(__REAL_INSTALL))
@echo "Ignore install for $(__REAL_INSTALL)"
else
install:
mkdir -p $(__REAL_INSTALL)
rm -rf $(__REAL_INSTALL)/usr
rm -rf $(__REAL_INSTALL)
mkdir -p $(__REAL_INSTALL)/mgmt $(__REAL_INSTALL)/platform $(__REAL_INSTALL)/ui
cp -rf mgmt $(__REAL_INSTALL)/mgmt
cp -rf ui/build $(__REAL_INSTALL)/ui/build
cp -f platform/platform $(__REAL_INSTALL)/platform/platform
cp -f platform/bootstrap $(__REAL_INSTALL)/platform/bootstrap
cp -rf platform/auto $(__REAL_INSTALL)/platform/auto
cp -rf platform/containers $(__REAL_INSTALL)/platform/containers
rm -rf $(__REAL_INSTALL)/platform/containers/objs/*
cp -rf usr $(__REAL_INSTALL)/usr
sed -i "s|/usr/local/srs-cloud|$(SRS_PREFIX)|g" $(__REAL_INSTALL)/usr/lib/systemd/system/srs-cloud.service
sed -i "s|/usr/local/srs-cloud|$(PREFIX)|g" $(__REAL_INSTALL)/usr/lib/systemd/system/srs-cloud.service
endif

uninstall:
@echo "rmdir $(SRS_PREFIX)"
rm -rf $(SRS_PREFIX)
ifeq ($(shell pwd), $(__REAL_INSTALL))
@echo "Ignore uninstall for $(__REAL_INSTALL)"
else
rm -rf $(__REAL_INSTALL)

test:
cd platform && go test ./...
cd releases && go test ./...

cd ui && npm run test
39 changes: 3 additions & 36 deletions platform/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
.PHONY: default clean alpine platform-build platform-clean ui-install ui-build ui-build-cn ui-build-en ui-build-docker ui-clean build help
.PHONY: default clean alpine build

default: build

help:
@echo "Usage: make build|clean"
@echo " default Build the platform only"
@echo " build Build the platform and ui"
@echo " clean Cleanup the platform and ui"
@echo " platform-build Use Go to build the platform"
@echo " platform-clean Cleanup the platform"
@echo " ui-install Use npm install for dependencies for ui"
@echo " ui-build Use npm run build for building ui"
@echo " ui-clean Cleanup the ui"
build: ./platform

build: platform-build ui-install ui-build

clean: ui-clean platform-clean

platform-build: ./platform

platform-clean:
clean:
rm -f platform

./platform: *.go Makefile go.mod
Expand All @@ -28,21 +13,3 @@ platform-clean:
# Build for alpine, see https://www.cloudbees.com/blog/building-minimal-docker-containers-for-go-applications
alpine:
CGO_ENABLED=0 GOOS=linux go build -mod=vendor -a -installsuffix cgo -o platform .

ui-install:
cd ui && npm install

ui-build:
cd ui && env PUBLIC_URL=/mgmt REACT_APP_LOCALE=zh BUILD_PATH=build/zh npm run build

ui-build-cn:
cd ui && env PUBLIC_URL=/mgmt REACT_APP_LOCALE=zh BUILD_PATH=build/zh npm run build

ui-build-en:
cd ui && env PUBLIC_URL=/mgmt REACT_APP_LOCALE=en BUILD_PATH=build/en npm run build

ui-build-docker:
cd ui && npm run build

ui-clean:
rm -rf ui/build
2 changes: 1 addition & 1 deletion platform/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ func handleDockerHTTPService(ctx context.Context, handler *http.ServeMux) error
})

// Serve UI at platform.
fileRoot := path.Join(conf.Pwd, "ui/build")
fileRoot := path.Join(conf.Pwd, "../ui/build")
if os.Getenv("REACT_APP_LOCALE") != "" {
fileRoot = path.Join(fileRoot, os.Getenv("REACT_APP_LOCALE"))
} else {
Expand Down
File renamed without changes.
20 changes: 20 additions & 0 deletions ui/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.PHONY: default clean build
.PHONY: npm build-cn build-en

default: build

build: npm build build-cn build-en

npm:
npm install

build: build-cn

build-cn:
env PUBLIC_URL=/mgmt REACT_APP_LOCALE=zh BUILD_PATH=build/zh npm run build

build-en:
env PUBLIC_URL=/mgmt REACT_APP_LOCALE=en BUILD_PATH=build/en npm run build

clean:
rm -rf ui/build
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 56594ab

Please sign in to comment.