feat: 添加docker-compose配置和用户管理逻辑更新
fix(ci): 移除敏感信息并更新SSH认证方式 refactor: 清理无用文件和更新Makefile配置 docs: 添加项目配置文件和更新环境变量说明
This commit is contained in:
parent
cc6ebc18e5
commit
a73a3f2313
@ -11,8 +11,6 @@ on:
|
|||||||
env:
|
env:
|
||||||
# Docker
|
# Docker
|
||||||
REPO: ${{ vars.REPO }}
|
REPO: ${{ vars.REPO }}
|
||||||
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
|
|
||||||
DOCKER_PASSWORD: ${{ vars.DOCKER_PASSWORD}}
|
|
||||||
# Gitea
|
# Gitea
|
||||||
GIT_USERNAME: ${{ vars.GIT_USERNAME }}
|
GIT_USERNAME: ${{ vars.GIT_USERNAME }}
|
||||||
GIT_PASSWORD: ${{ vars.GIT_PASSWORD }}
|
GIT_PASSWORD: ${{ vars.GIT_PASSWORD }}
|
||||||
@ -20,11 +18,7 @@ env:
|
|||||||
SSH_HOST: ${{ vars.SSH_HOST }}
|
SSH_HOST: ${{ vars.SSH_HOST }}
|
||||||
SSH_PORT: ${{ vars.SSH_PORT }}
|
SSH_PORT: ${{ vars.SSH_PORT }}
|
||||||
SSH_USER: ${{ vars.SSH_USER }}
|
SSH_USER: ${{ vars.SSH_USER }}
|
||||||
SSH_PASSWORD: ${{ vars.SSH_PASSWORD }}
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
# SMTP
|
|
||||||
SMTP_SERVER_ADDRESS: ${{ vars.SMTP_SERVER_ADDRESS }}
|
|
||||||
SMTP_USERNAME: ${{ vars.SMTP_USERNAME }}
|
|
||||||
SMTP_PASSWORD: ${{ vars.SMTP_PASSWORD }}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
linux:
|
linux:
|
||||||
@ -44,7 +38,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
host: ${{ env.SSH_HOST }}
|
host: ${{ env.SSH_HOST }}
|
||||||
username: ${{ env.SSH_USER }}
|
username: ${{ env.SSH_USER }}
|
||||||
password: ${{ env.SSH_PASSWORD }}
|
key: ${{ env.SSH_PRIVATE_KEY }}
|
||||||
port: ${{ env.SSH_PORT }}
|
port: ${{ env.SSH_PORT }}
|
||||||
debug: true
|
debug: true
|
||||||
script: |
|
script: |
|
||||||
@ -55,9 +49,6 @@ jobs:
|
|||||||
source ./.env
|
source ./.env
|
||||||
docker cp .env ${{ vars.RUNNER_CONTAINER_NAME }}:/.env
|
docker cp .env ${{ vars.RUNNER_CONTAINER_NAME }}:/.env
|
||||||
docker exec ${{ vars.RUNNER_CONTAINER_NAME }} /bin/bash -c "source /.env"
|
docker exec ${{ vars.RUNNER_CONTAINER_NAME }} /bin/bash -c "source /.env"
|
||||||
mkdir -p ${HOST_APIDOC_DIRCTORY}
|
|
||||||
cd ${HOST_APIDOC_DIRCTORY}
|
|
||||||
docker cp ${{env.JOB_CONTAINER_NAME}}:${{gitea.WORKSPACE}}/${SERVICE_NAME}.json .
|
|
||||||
|
|
||||||
- name: Install Go environment
|
- name: Install Go environment
|
||||||
uses: https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/actions/gitea-tool-cache@v5
|
uses: https://${{ env.GIT_USERNAME }}:${{ env.GIT_PASSWORD }}@${{ vars.DOMAIN_OF_GITEA}}/actions/gitea-tool-cache@v5
|
||||||
|
|||||||
50
.github/workflows/develop.yaml
vendored
50
.github/workflows/develop.yaml
vendored
@ -1,50 +0,0 @@
|
|||||||
name: Deploy
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: ["develop"]
|
|
||||||
pull_request:
|
|
||||||
branches: ["develop"]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-deploy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Get short Git commit ID
|
|
||||||
id: vars
|
|
||||||
run: echo "COMMIT_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
|
|
||||||
- name: Build Docker image
|
|
||||||
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/ppanel-server-dev:${{ env.COMMIT_ID }} .
|
|
||||||
|
|
||||||
- name: Push Docker image
|
|
||||||
run: docker push ${{ secrets.DOCKER_USERNAME }}/ppanel-server-dev:${{ env.COMMIT_ID }}
|
|
||||||
|
|
||||||
- name: Deploy to server
|
|
||||||
uses: appleboy/ssh-action@v0.1.6
|
|
||||||
with:
|
|
||||||
host: ${{ secrets.SSH_HOST }}
|
|
||||||
username: ${{ secrets.SSH_USER }}
|
|
||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
||||||
script: |
|
|
||||||
if [ $(docker ps -a -q -f name=ppanel-server-dev) ]; then
|
|
||||||
echo "Stopping and removing existing ppanel-server container..."
|
|
||||||
docker stop ppanel-server-dev
|
|
||||||
docker rm ppanel-server-dev
|
|
||||||
else
|
|
||||||
echo "No existing ppanel-server-dev container running."
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
docker run -d --restart=always --log-driver=journald --name ppanel-server-dev -p 8080:8080 -v /www/wwwroot/api/etc:/app/etc --restart=always -d ${{ secrets.DOCKER_USERNAME }}/ppanel-server-dev:${{ env.COMMIT_ID }}
|
|
||||||
131
.github/workflows/release.yml
vendored
131
.github/workflows/release.yml
vendored
@ -1,131 +0,0 @@
|
|||||||
name: Release
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
env:
|
|
||||||
IMAGE_NAME: ppanel-server
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Extract version from git tag
|
|
||||||
id: version
|
|
||||||
run: echo "VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Get short SHA
|
|
||||||
id: sha
|
|
||||||
run: echo "GIT_SHA=${GITHUB_SHA::8}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Set BUILD_TIME env
|
|
||||||
run: echo BUILD_TIME=$(date --iso-8601=seconds) >> ${GITHUB_ENV}
|
|
||||||
|
|
||||||
|
|
||||||
- name: Build and push Docker image for main release
|
|
||||||
if: "!contains(github.ref_name, 'beta')"
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: Dockerfile
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
build-args: |
|
|
||||||
VERSION=${{ env.VERSION }}
|
|
||||||
tags: |
|
|
||||||
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest
|
|
||||||
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.GIT_SHA }}
|
|
||||||
|
|
||||||
- name: Build and push Docker image for beta release
|
|
||||||
if: contains(github.ref_name, 'beta')
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: Dockerfile
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
build-args: |
|
|
||||||
VERSION=${{ env.VERSION }}
|
|
||||||
tags: |
|
|
||||||
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:beta
|
|
||||||
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.GIT_SHA }}
|
|
||||||
|
|
||||||
release-notes:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build-docker
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up Go
|
|
||||||
uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: '1.21'
|
|
||||||
|
|
||||||
- name: Install GoReleaser
|
|
||||||
run: |
|
|
||||||
go install github.com/goreleaser/goreleaser/v2@latest
|
|
||||||
|
|
||||||
- name: Run GoReleaser
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
||||||
run: |
|
|
||||||
goreleaser check
|
|
||||||
goreleaser release --clean
|
|
||||||
|
|
||||||
releases-matrix:
|
|
||||||
name: Release ppanel-server binary
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: release-notes # wait for release-notes job to finish
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
# build and publish in parallel: linux/386, linux/amd64, linux/arm64,
|
|
||||||
# windows/386, windows/amd64, windows/arm64, darwin/amd64, darwin/arm64
|
|
||||||
goos: [ linux, windows, darwin ]
|
|
||||||
goarch: [ '386', amd64, arm64 ]
|
|
||||||
exclude:
|
|
||||||
- goarch: '386'
|
|
||||||
goos: darwin
|
|
||||||
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Extract version from git tag
|
|
||||||
id: version
|
|
||||||
run: echo "VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Set BUILD_TIME env
|
|
||||||
run: echo BUILD_TIME=$(date --iso-8601=seconds) >> ${GITHUB_ENV}
|
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: wangyoucao577/go-release-action@v1
|
|
||||||
with:
|
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
goos: ${{ matrix.goos }}
|
|
||||||
goarch: ${{ matrix.goarch }}
|
|
||||||
asset_name: "ppanel-server-${{ matrix.goos }}-${{ matrix.goarch }}"
|
|
||||||
goversion: "https://dl.google.com/go/go1.23.3.linux-amd64.tar.gz"
|
|
||||||
project_path: "."
|
|
||||||
binary_name: "ppanel-server"
|
|
||||||
extra_files: LICENSE etc
|
|
||||||
ldflags: -X "github.com/perfect-panel/server/pkg/constant.Version=${{env.VERSION}}" -X "github.com/perfect-panel/server/pkg/constant.BuildTime=${{env.BUILD_TIME}}"
|
|
||||||
83
.github/workflows/swagger.yaml
vendored
83
.github/workflows/swagger.yaml
vendored
@ -1,83 +0,0 @@
|
|||||||
name: Go CI/CD with goctl and Swagger
|
|
||||||
|
|
||||||
on:
|
|
||||||
# release:
|
|
||||||
# types: [published]
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- develop
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Install goctl
|
|
||||||
run: |
|
|
||||||
curl -L https://github.com/zeromicro/go-zero/releases/download/tools%2Fgoctl%2Fv1.7.2/goctl-v1.7.2-linux-amd64.tar.gz -o goctl-v1.7.2-linux-amd64.tar.gz
|
|
||||||
tar -xvzf goctl-v1.7.2-linux-amd64.tar.gz
|
|
||||||
chmod +x goctl
|
|
||||||
sudo mv goctl /usr/local/bin/goctl
|
|
||||||
goctl --version
|
|
||||||
|
|
||||||
- name: Install goctl-swagger
|
|
||||||
run: |
|
|
||||||
curl -L https://github.com/tensionc/goctl-swagger/releases/download/v1.0.1/goctl-swagger-v1.0.1-linux-amd64.tar.gz -o goctl-swagger.tar.gz
|
|
||||||
tar -xvzf goctl-swagger.tar.gz
|
|
||||||
chmod +x goctl-swagger
|
|
||||||
sudo mv goctl-swagger /usr/local/bin/
|
|
||||||
|
|
||||||
- name: Generate Swagger file
|
|
||||||
run: |
|
|
||||||
mkdir -p swagger
|
|
||||||
goctl api plugin -plugin goctl-swagger='swagger -filename common.json -pack Response -response "[{\"name\":\"code\",\"type\":\"integer\",\"description\":\"状态码\"},{\"name\":\"msg\",\"type\":\"string\",\"description\":\"消息\"},{\"name\":\"data\",\"type\":\"object\",\"description\":\"数据\",\"is_data\":true}]";' -api ./apis/swagger_common.api -dir ./swagger
|
|
||||||
goctl api plugin -plugin goctl-swagger='swagger -filename user.json -pack Response -response "[{\"name\":\"code\",\"type\":\"integer\",\"description\":\"状态码\"},{\"name\":\"msg\",\"type\":\"string\",\"description\":\"消息\"},{\"name\":\"data\",\"type\":\"object\",\"description\":\"数据\",\"is_data\":true}]";' -api ./apis/swagger_user.api -dir ./swagger
|
|
||||||
goctl api plugin -plugin goctl-swagger='swagger -filename app.json -pack Response -response "[{\"name\":\"code\",\"type\":\"integer\",\"description\":\"状态码\"},{\"name\":\"msg\",\"type\":\"string\",\"description\":\"消息\"},{\"name\":\"data\",\"type\":\"object\",\"description\":\"数据\",\"is_data\":true}]";' -api ./apis/swagger_app.api -dir ./swagger
|
|
||||||
goctl api plugin -plugin goctl-swagger='swagger -filename admin.json -pack Response -response "[{\"name\":\"code\",\"type\":\"integer\",\"description\":\"状态码\"},{\"name\":\"msg\",\"type\":\"string\",\"description\":\"消息\"},{\"name\":\"data\",\"type\":\"object\",\"description\":\"数据\",\"is_data\":true}]";' -api ./apis/swagger_admin.api -dir ./swagger
|
|
||||||
goctl api plugin -plugin goctl-swagger='swagger -filename ppanel.json -pack Response -response "[{\"name\":\"code\",\"type\":\"integer\",\"description\":\"状态码\"},{\"name\":\"msg\",\"type\":\"string\",\"description\":\"消息\"},{\"name\":\"data\",\"type\":\"object\",\"description\":\"数据\",\"is_data\":true}]";' -api ppanel.api -dir ./swagger
|
|
||||||
goctl api plugin -plugin goctl-swagger='swagger -filename node.json -pack Response -response "[{\"name\":\"code\",\"type\":\"integer\",\"description\":\"状态码\"},{\"name\":\"msg\",\"type\":\"string\",\"description\":\"消息\"},{\"name\":\"data\",\"type\":\"object\",\"description\":\"数据\",\"is_data\":true}]";' -api ./apis/swagger_node.api -dir ./swagger
|
|
||||||
|
|
||||||
|
|
||||||
- name: Verify Swagger file
|
|
||||||
run: |
|
|
||||||
test -f ./swagger/common.json
|
|
||||||
test -f ./swagger/user.json
|
|
||||||
test -f ./swagger/app.json
|
|
||||||
test -f ./swagger/admin.json
|
|
||||||
|
|
||||||
- name: Checkout target repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: perfect-panel/ppanel-docs
|
|
||||||
token: ${{ secrets.GH_TOKEN }}
|
|
||||||
path: ppanel-docs
|
|
||||||
persist-credentials: true
|
|
||||||
|
|
||||||
- name: Verify or create public/swagger directory
|
|
||||||
run: |
|
|
||||||
mkdir -p ./ppanel-docs/public/swagger
|
|
||||||
|
|
||||||
- name: Copy Swagger files
|
|
||||||
run: |
|
|
||||||
cp -rf swagger/* ppanel-docs/public/swagger
|
|
||||||
cd ppanel-docs
|
|
||||||
|
|
||||||
- name: Check for file changes
|
|
||||||
run: |
|
|
||||||
cd ppanel-docs
|
|
||||||
git add .
|
|
||||||
git status
|
|
||||||
if [ "$(git status --porcelain)" ]; then
|
|
||||||
echo "Changes detected in the doc repository."
|
|
||||||
git config user.name "GitHub Actions"
|
|
||||||
git config user.email "actions@ppanel.dev"
|
|
||||||
git commit -m "Update Swagger files"
|
|
||||||
git push
|
|
||||||
else
|
|
||||||
echo "No changes detected."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="go build github.com/perfect-panel/server" type="GoApplicationRunConfiguration" factoryName="Go Application" nameIsGenerated="true">
|
|
||||||
<module name="server" />
|
|
||||||
<working_directory value="$PROJECT_DIR$" />
|
|
||||||
<parameters value="run --config etc/ppanel-dev.yaml" />
|
|
||||||
<envs>
|
|
||||||
<env name="PPANEL_MODE" value="demo" />
|
|
||||||
</envs>
|
|
||||||
<kind value="PACKAGE" />
|
|
||||||
<package value="github.com/perfect-panel/server" />
|
|
||||||
<directory value="$PROJECT_DIR$" />
|
|
||||||
<filePath value="$PROJECT_DIR$/ppanel.go" />
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
41
Makefile
41
Makefile
@ -1,14 +1,14 @@
|
|||||||
# Custom configuration | 独立配置
|
# Custom configuration | 独立配置
|
||||||
# Service name | 项目名称
|
# Service name | 项目名称
|
||||||
SERVICE=Miniapp
|
SERVICE=Mininppp
|
||||||
# Service name in specific style | 项目经过style格式化的名称
|
# Service name in specific style | 项目经过style格式化的名称
|
||||||
SERVICE_STYLE=miniapp
|
SERVICE_STYLEminia=mpp
|
||||||
# Service name in lowercase | 项目名称全小写格式
|
# Service name in lowercase | 项目名称全小写格式
|
||||||
SERVICE_LOWER=miniapp
|
SERVICE_LOWEminiaR=app
|
||||||
# Service name in snake format | 项目名称下划线格式
|
# Service name in snake format | 项目名称下划线格式
|
||||||
SERVICE_SNAKE=miniapp
|
SERVICE_SNAminiaKEiapp
|
||||||
# Service name in snake format | 项目名称短杠格式
|
# Service name in snake format | 项目名称短杠格式
|
||||||
SERVICE_DASH=miniapp
|
SERVICE_DminiaASniapp
|
||||||
|
|
||||||
# The project version, if you don't use git, you should set it manually | 项目版本,如果不使用git请手动设置
|
# The project version, if you don't use git, you should set it manually | 项目版本,如果不使用git请手动设置
|
||||||
VERSION=$(shell git describe --tags --always)
|
VERSION=$(shell git describe --tags --always)
|
||||||
@ -20,36 +20,18 @@ PROJECT_STYLE=go_zero
|
|||||||
PROJECT_I18N=true
|
PROJECT_I18N=true
|
||||||
|
|
||||||
# The suffix after build or compile | 构建后缀
|
# The suffix after build or compile | 构建后缀
|
||||||
PROJECT_BUILD_SUFFIX=api
|
PROJECT_BUILD_SUapiFFIX=api
|
||||||
|
|
||||||
# Swagger type, support yml,json | Swagger 文件类型,支持yml,json
|
# Swagger type, support yml,json | Swagger 文件类型,支持yml,json
|
||||||
SWAGGER_TYPE=json
|
SWAGGER_TYP
|
||||||
|
E=json
|
||||||
|
|
||||||
|
|
||||||
# The arch of the build | 构建的架构
|
# The arch of the build | 构建的架构
|
||||||
GOARCH=amd64
|
GOARCH=amd64
|
||||||
|
|
||||||
# The repository of docker | Docker 仓库地址
|
# The repository of docker | Docker 仓库地址
|
||||||
DOCKER_REPO=docker.io/xxx
|
DOCKER_REPO=docker.i.on ticcheck
|
||||||
|
|
||||||
# ---- You may not need to modify the codes below | 下面的代码大概率不需要更改 ----
|
|
||||||
|
|
||||||
GO ?= go
|
|
||||||
GOFMT ?= gofmt "-s"
|
|
||||||
GOFILES := $(shell find . -name "*.go")
|
|
||||||
LDFLAGS := -s -w
|
|
||||||
|
|
||||||
.PHONY: test
|
|
||||||
test: # Run test for the project | 运行项目测试
|
|
||||||
go test -v --cover ./internal/..
|
|
||||||
|
|
||||||
.PHONY: fmt
|
|
||||||
fmt: # Format the codes | 格式化代码
|
|
||||||
$(GOFMT) -w $(GOFILES)
|
|
||||||
|
|
||||||
.PHONY: lint
|
|
||||||
lint: # Run go linter | 运行代码错误分析
|
|
||||||
golangci-lint run -D staticcheck
|
|
||||||
|
|
||||||
.PHONY: tools
|
.PHONY: tools
|
||||||
tools: # Install the necessary tools | 安装必要的工具
|
tools: # Install the necessary tools | 安装必要的工具
|
||||||
@ -109,11 +91,10 @@ build-mac: # Build project for MacOS | 构建MacOS下的可执行文件
|
|||||||
env CGO_ENABLED=0 GOOS=darwin GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_$(PROJECT_BUILD_SUFFIX) $(SERVICE_STYLE).go
|
env CGO_ENABLED=0 GOOS=darwin GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_$(PROJECT_BUILD_SUFFIX) $(SERVICE_STYLE).go
|
||||||
@echo "Build project for MacOS successfully"
|
@echo "Build project for MacOS successfully"
|
||||||
|
|
||||||
.PHONY: build-linux
|
.PHONY: build#oject for Linux | 构建Linx下的可执行文件
|
||||||
build-linux: # Build project for Linux | 构建Linux下的可执行文件
|
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_$(PROJECT_BUILD_SUFFIX) $(SERVICE_STYLE).go
|
env CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -trimpath -o $(SERVICE_STYLE)_$(PROJECT_BUILD_SUFFIX) $(SERVICE_STYLE).go
|
||||||
@echo "Build project for Linux successfully"
|
@echo "Build project for Linux successfully"
|
||||||
|
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
help: # Show help | 显示帮助
|
help: # Show help | 显示帮助
|
||||||
@grep -E '^[a-zA-Z0-9 -]+:.*#' Makefile | sort | while read -r l; do printf "\033[1;32m$$(echo $$l | cut -f 1 -d':')\033[00m:$$(echo $$l | cut -f 2- -d'#')\n"; done
|
@grep kfile | sort | while read-r l; do printf "\033[1;32m$$(echo $$l | cut -f 1 -d':')\033[00m:$$(echo $$l | cut -f 2- -d'#')\n"; done
|
||||||
|
|||||||
31
deploy/.env
Normal file
31
deploy/.env
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#******** MODIFY THE FOLLOWING VARIABLES TO YOUR OWN SETTINGS ********#
|
||||||
|
# 构建说明:
|
||||||
|
# 1. docker-compose.yaml文件放置目录为:/deploy/docker-compose/project/
|
||||||
|
# 2. 将swagger json文件添加至 api dockerfile的app目录中,用于两个容器之间的文件中转。
|
||||||
|
|
||||||
|
# PROJECT DEFINE
|
||||||
|
export DOMAIN=ppanel.kxsw.us
|
||||||
|
export PROJECT_NAME=ppanel # 容器项目名称
|
||||||
|
export SERVICE_NAME=server # 容器服务名称
|
||||||
|
export API_INNER_PORT=8080
|
||||||
|
export API_EXTERNAL_PORT=8080
|
||||||
|
|
||||||
|
# Container Repository
|
||||||
|
export REGISTRY_URL=registry.kxsw.us # 本地 Docker Registry 地址,请根据实际情况修改
|
||||||
|
export REGISTRY_NAMESPACE=ppanel # 镜像仓库命名空间
|
||||||
|
# Project DockerCompose File
|
||||||
|
export DOCKER_COMPOSE_FILE=deploy/project/docker-compose.yaml
|
||||||
|
|
||||||
|
# DOCKER VARS
|
||||||
|
export DOCKER_PROJECT_NAME=${PROJECT_NAME}-${SERVICE_NAME} # 项目名称,需要保持全局唯一
|
||||||
|
|
||||||
|
export DOCKER_NETWORK_NAME=ppanel
|
||||||
|
# API DOCKER DEFINE don't forget modify the service name in docker-compose file
|
||||||
|
export API_PROJECT_BUILD_SUFFIX=api
|
||||||
|
export API_LOG_DIR=/home/logs/${PROJECT_NAME}-${SERVICE_NAME}/${API_PROJECT_BUILD_SUFFIX}
|
||||||
|
export GITEA_RUNNER_NAME=kxsw-runner #*修改为你自己的gitea-runner容器名称
|
||||||
|
|
||||||
|
#******** DON'T MODIFY THE FOLLOWING VARIABLES ********#
|
||||||
|
#### API ENVS
|
||||||
|
export API_IMAGE_NAME=${REGISTRY_URL}/${REGISTRY_NAMESPACE}/${PROJECT_NAME}-${SERVICE_NAME}-${API_PROJECT_BUILD_SUFFIX}
|
||||||
|
export API_CONTAINER_NAME=${PROJECT_NAME}-${SERVICE_NAME}-${API_PROJECT_BUILD_SUFFIX}
|
||||||
15
deploy/project/docker-compose.yaml
Normal file
15
deploy/project/docker-compose.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
services:
|
||||||
|
# need modify service name to your owner
|
||||||
|
server-api:
|
||||||
|
image: ${API_IMAGE_NAME}
|
||||||
|
container_name: ${API_CONTAINER_NAME}
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- ${API_EXTERNAL_PORT}:${API_INNER_PORT}
|
||||||
|
volumes:
|
||||||
|
- ${API_LOG_DIR}:/app/logs
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
name: ${DOCKER_NETWORK_NAME}
|
||||||
|
external: true
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
Host: 0.0.0.0
|
||||||
|
Port: 8080
|
||||||
|
TLS:
|
||||||
|
Enable: false
|
||||||
|
CertFile: ""
|
||||||
|
KeyFile: ""
|
||||||
|
Debug: false
|
||||||
|
JwtAuth:
|
||||||
|
AccessSecret: 89270267-f1dc-4136-9c9c-dc38c4685d63
|
||||||
|
AccessExpire: 604800
|
||||||
|
Logger:
|
||||||
|
ServiceName: PPanel
|
||||||
|
Mode: file
|
||||||
|
Encoding: json
|
||||||
|
TimeFormat: "2006-01-02 15:04:05.000"
|
||||||
|
Path: logs
|
||||||
|
Level: info
|
||||||
|
MaxContentLength: 0
|
||||||
|
Compress: false
|
||||||
|
Stat: true
|
||||||
|
KeepDays: 0
|
||||||
|
StackCooldownMillis: 100
|
||||||
|
MaxBackups: 0
|
||||||
|
MaxSize: 0
|
||||||
|
Rotation: daily
|
||||||
|
FileTimeFormat: 2006-01-02T15:04:05.000Z07:00
|
||||||
|
MySQL:
|
||||||
|
Addr: localhost:3306
|
||||||
|
Username: root
|
||||||
|
Password: "123456"
|
||||||
|
Dbname: ppanel_admin
|
||||||
|
Config: charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai
|
||||||
|
MaxIdleConns: 10
|
||||||
|
MaxOpenConns: 10
|
||||||
|
SlowThreshold: 1000
|
||||||
|
Redis:
|
||||||
|
Host: 127.0.0.1:6379
|
||||||
|
Pass: ""
|
||||||
|
DB: 0
|
||||||
@ -44,6 +44,8 @@ func (l *UpdateUserBasicInfoLogic) UpdateUserBasicInfo(req *types.UpdateUserBasi
|
|||||||
userInfo.Balance = req.Balance
|
userInfo.Balance = req.Balance
|
||||||
userInfo.GiftAmount = req.GiftAmount
|
userInfo.GiftAmount = req.GiftAmount
|
||||||
userInfo.Commission = req.Commission
|
userInfo.Commission = req.Commission
|
||||||
|
userInfo.IsAdmin = &req.IsAdmin
|
||||||
|
userInfo.Enable = &req.Enable
|
||||||
|
|
||||||
if req.Password != "" {
|
if req.Password != "" {
|
||||||
if userInfo.Id == 2 && isDemo {
|
if userInfo.Id == 2 && isDemo {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user