Skip to content

Commit

Permalink
add parameters and docker
Browse files Browse the repository at this point in the history
  • Loading branch information
thun888 committed Aug 29, 2023
1 parent 1607824 commit 6faa73d
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 82 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/buildapp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build and Release
run-name: Build ${{ github.event.inputs.version }} by @${{ github.actor }}

on:
workflow_dispatch:
inputs:
version:
description: '版本号'
required: true


jobs:
build:
runs-on: ubuntu-latest

steps:

- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
with:
event-type: mrui-release
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Install UPX
run: sudo apt-get install upx

- name: download modules
run: go mod download

- name: Run build script
run: bash build.sh ${{ github.event.inputs.version }} > temp.txt

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
tag_name: ${{ github.event.inputs.version }}
release_name: Release ${{ github.event.inputs.version }}
draft: true
prerelease: false

- name: Upload Release Assets
run: |
for file in ./build/*; do
if [ -f "$file" ]; then
echo "Uploading $file"
curl \
-H "Authorization: token ${{ secrets.TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $file)" \
--data-binary @"$file" \
"${{ steps.create_release.outputs.upload_url }}=$(basename $file)"
fi
done
- name: send telegram message on push
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
document: ./temp.txt
34 changes: 34 additions & 0 deletions .github/workflows/builddocker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: build-docker

on:
repository_dispatch:
types: [mrui-release]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/386,linux/arm64
push: true
tags: thun888/mirouter-ui:latest
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM golang:1.21.0-alpine3.18 AS builder

WORKDIR /app

COPY . .

RUN go mod download

RUN go build -o main .

FROM alpine:3.18

WORKDIR /app

COPY --from=builder /app/main /app/main

EXPOSE 6789

CMD ["./main","--config=/app/data/config.json","--basedirectory=/app/data/"]
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
![mrui-logo](https://github.com/Mirouterui/mirouter-ui/assets/63234268/da737f28-e8b6-42d7-a21e-70be2d53fb78)

## Mirouter-ui | 基于小米路由器API的展示面板
## Mirouter-ui

> 基于小米路由器API的展示面板
将本程序部署在小米路由器的网络环境中,配置完成即可食用

Expand All @@ -10,7 +12,7 @@

部分新路由无法获取cpu占用,如红米AX6000,AX1800。可在路由器上运行解决

### 图片展示
## 图片展示

#### 首页

Expand All @@ -34,7 +36,15 @@
![Snipaste_2023-08-25_13-33-54](https://github.com/Mirouterui/mirouter-ui/assets/63234268/0926dafd-a63e-4ee6-bc61-f381c1dfc199)


### 部署
## 部署

### Docker

> docker run -d -p 6789:6789 -v $(pwd):/app/data thun888/mirouter-ui
新建一个文件夹,并在该文件夹里运行上述命令,程序会在该文件夹里生成配置文件,修改即可

### 直接运行

#### 下载

Expand Down Expand Up @@ -78,6 +88,15 @@
| port | 6789 | 网页页面端口号 |
| debug | true | debug模式,建议在测试正常后关闭 |

命令行参数:

| 参数 | 解释 |
| --------------- | -------------------------------- |
| --config | 配置文件路径 |
| --basedirectory | 基础目录路径,在里面存放静态文件 |



然后运行程序

如果遇到防火墙提示请勾上两个勾并确定
Expand Down
93 changes: 38 additions & 55 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,77 +1,60 @@
read -p "版本号: " VERSION
if [ -z "$1" ]
then
read -p "版本号: " VERSION
else
VERSION=$1
fi
echo "版本号是:$VERSION"
echo "Building MirouterUI $VERSION..."
echo "Deleting old build..."
rm mirouterui_win_amd64.exe
rm mirouterui_win_386.exe
rm mirouterui_win_arm64.exe
rm mirouterui_linux_amd64
rm mirouterui_linux_arm64
rm mirouterui_linux_mipsle
rm mirouterui_linux_mips
rm mirouterui_linux_armv5
rm mirouterui_linux_armv6
rm mirouterui_linux_armv7
rm mirouterui_darwin_amd64
rm mirouterui_darwin_arm64
OUTPUT_DIR="./build"
echo "编译生成目录:$OUTPUT_DIR"
mkdir -p $OUTPUT_DIR

echo "Building win_amd64"
GOOS=windows GOARCH=amd64 go build main.go
mv main.exe mirouterui_win_amd64_noupx_$VERSION.exe
upx --best -o mirouterui_win_amd64_$VERSION.exe mirouterui_win_amd64_noupx_$VERSION.exe
GOOS=windows GOARCH=amd64 go build -o $OUTPUT_DIR/mirouterui_win_amd64_noupx_$VERSION.exe main.go
upx --best -o $OUTPUT_DIR/mirouterui_win_amd64_$VERSION.exe $OUTPUT_DIR/mirouterui_win_amd64_noupx_$VERSION.exe

echo "Building win_386"
GOOS=windows GOARCH=386 go build main.go
mv main.exe mirouterui_win_386_noupx_$VERSION.exe
upx --best -o mirouterui_win_386_$VERSION.exe mirouterui_win_386_noupx_$VERSION.exe
GOOS=windows GOARCH=386 go build -o $OUTPUT_DIR/mirouterui_win_386_noupx_$VERSION.exe main.go
upx --best -o $OUTPUT_DIR/mirouterui_win_386_$VERSION.exe $OUTPUT_DIR/mirouterui_win_386_noupx_$VERSION.exe

echo "Building win_arm64"
GOOS=windows GOARCH=arm64 go build main.go
mv main.exe mirouterui_win_arm64_noupx_$VERSION.exe
GOOS=windows GOARCH=arm64 go build -o $OUTPUT_DIR/mirouterui_win_arm64_noupx_$VERSION.exe main.go
# rm main.exe

echo "Building linux_amd64"
GOOS=linux GOARCH=amd64 go build main.go
mv main mirouterui_linux_amd64_noupx_$VERSION
upx --best -o mirouterui_linux_amd64_$VERSION mirouterui_linux_amd64_noupx_$VERSION
GOOS=linux GOARCH=amd64 go build -o $OUTPUT_DIR/mirouterui_linux_amd64_noupx_$VERSION main.go
upx --best -o $OUTPUT_DIR/mirouterui_linux_amd64_$VERSION $OUTPUT_DIR/mirouterui_linux_amd64_noupx_$VERSION

echo "Building linux_arm64"
GOOS=linux GOARCH=arm64 go build main.go
mv main mirouterui_linux_arm64_noupx_$VERSION
upx --best -o mirouterui_linux_arm64_$VERSION mirouterui_linux_arm64_noupx_$VERSION
GOOS=linux GOARCH=arm64 go build -o $OUTPUT_DIR/mirouterui_linux_arm64_noupx_$VERSION main.go
upx --best -o $OUTPUT_DIR/mirouterui_linux_arm64_$VERSION $OUTPUT_DIR/mirouterui_linux_arm64_noupx_$VERSION

echo "Building linux_mipsle"
GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build main.go
mv main mirouterui_linux_mipsle_noupx_$VERSION
upx --best -o mirouterui_linux_mipsle_$VERSION mirouterui_linux_mipsle_noupx_$VERSION
GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -o $OUTPUT_DIR/mirouterui_linux_mipsle_noupx_$VERSION main.go
upx --best -o $OUTPUT_DIR/mirouterui_linux_mipsle_$VERSION $OUTPUT_DIR/mirouterui_linux_mipsle_noupx_$VERSION

echo "Building linux_mips"
GOOS=linux GOARCH=mips GOMIPS=softfloat go build main.go
mv main mirouterui_linux_mips_noupx_$VERSION
upx --best -o mirouterui_linux_mips_$VERSION mirouterui_linux_mips_noupx_$VERSION
GOOS=linux GOARCH=mips GOMIPS=softfloat go build -o $OUTPUT_DIR/mirouterui_linux_mips_noupx_$VERSION main.go
upx --best -o $OUTPUT_DIR/mirouterui_linux_mips_$VERSION $OUTPUT_DIR/mirouterui_linux_mips_noupx_$VERSION

echo "Building linux_armv5"
GOOS=linux GOARCH=arm GOARM=5 GOMIPS=softfloat go build main.go
mv main mirouterui_linux_armv5_noupx_$VERSION
upx --best -o mirouterui_linux_armv5_$VERSION mirouterui_linux_armv5_noupx_$VERSION
echo "Building linux_s390x"
GOOS=linux GOARCH=s390x go build -o $OUTPUT_DIR/mirouterui_linux_s390x_noupx_$VERSION main.go
# upx --best -o $OUTPUT_DIR/mirouterui_linux_s390x_$VERSION $OUTPUT_DIR/mirouterui_linux_s390x_noupx_$VERSION

echo "Building linux_armv6"
GOOS=linux GOARCH=arm GOARM=6 GOMIPS=softfloat go build main.go
mv main mirouterui_linux_armv6_noupx_$VERSION
upx --best -o mirouterui_linux_armv6_$VERSION mirouterui_linux_armv6_noupx_$VERSION

echo "Building linux_armv7"
GOOS=linux GOARCH=arm GOARM=7 GOMIPS=softfloat go build main.go
mv main mirouterui_linux_armv7_noupx_$VERSION
upx --best -o mirouterui_linux_armv7_$VERSION mirouterui_linux_armv7_noupx_$VERSION
for version in 5 6 7
do
echo "Building linux_armv$version"
GOOS=linux GOARCH=arm GOARM=$version GOMIPS=softfloat go build -o $OUTPUT_DIR/mirouterui_linux_armv${version}_noupx_$VERSION main.go
upx --best -o $OUTPUT_DIR/mirouterui_linux_armv${version}_$VERSION $OUTPUT_DIR/mirouterui_linux_armv${version}_noupx_$VERSION
done

# Building darwin_amd64
echo "Building darwin_amd64"
GOOS=darwin GOARCH=amd64 go build main.go
mv main mirouterui_darwin_amd64_noupx_$VERSION
upx --best -o mirouterui_darwin_amd64_$VERSION mirouterui_darwin_amd64_noupx_$VERSION
GOOS=darwin GOARCH=amd64 go build -o $OUTPUT_DIR/mirouterui_darwin_amd64_noupx_$VERSION main.go
upx --best -o $OUTPUT_DIR/mirouterui_darwin_amd64_$VERSION $OUTPUT_DIR/mirouterui_darwin_amd64_noupx_$VERSION

# Building darwin_arm64
echo "Building darwin_arm64"
GOOS=darwin GOARCH=arm64 go build main.go
mv main mirouterui_darwin_arm64_noupx_$VERSION
upx --best -o mirouterui_darwin_arm64_$VERSION mirouterui_darwin_arm64_noupx_$VERSION
# rm main

GOOS=darwin GOARCH=arm64 go build -o $OUTPUT_DIR/mirouterui_darwin_arm64_noupx_$VERSION main.go
upx --best -o $OUTPUT_DIR/mirouterui_darwin_arm64_$VERSION $OUTPUT_DIR/mirouterui_darwin_arm64_noupx_$VERSION
Loading

0 comments on commit 6faa73d

Please sign in to comment.