init basic project
This commit is contained in:
commit
a2edbf58e3
|
@ -0,0 +1,6 @@
|
|||
.idea/
|
||||
go.sum
|
||||
account/
|
||||
gen_result/
|
||||
etc/demo.yaml
|
||||
./client
|
|
@ -0,0 +1,47 @@
|
|||
###########
|
||||
# BUILDER #
|
||||
###########
|
||||
|
||||
FROM golang:1.20 as builder
|
||||
|
||||
ARG VERSION
|
||||
ARG BUILT
|
||||
ARG GIT_COMMIT
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install git
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
# Download public key for yt.com
|
||||
RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan yt.com >> ~/.ssh/known_hosts
|
||||
|
||||
# Forces the usage of git and ssh key fwded by ssh-agent for yt.com git repos
|
||||
RUN git config --global url."git@yt.com:".insteadOf "https://yt.com"
|
||||
|
||||
# private go packages
|
||||
ENV GOPRIVATE=yt.com
|
||||
|
||||
RUN --mount=type=ssh go mod download
|
||||
|
||||
ENV FLAG="-s -w -X main.Version=${VERSION} -X main.Built=${BUILT} -X main.GitCommit=${GIT_COMMIT}"
|
||||
|
||||
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \
|
||||
-ldflags "$FLAG" \
|
||||
-o /permission-server ./cmd/permission
|
||||
|
||||
#########
|
||||
# FINAL #
|
||||
#########
|
||||
|
||||
FROM oraclelinux:9-slim AS final
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /permission-server /app/permission-server
|
||||
COPY --from=builder /app/configs/config-example.yaml /app/config.yaml
|
||||
COPY --from=builder /app/configs/rbac_model.conf /app/rbac_model.conf
|
||||
|
||||
CMD ["/app/permission-server"]
|
|
@ -0,0 +1 @@
|
|||
// TODO 未來要放 helm 的地方
|
|
@ -0,0 +1 @@
|
|||
如果有需要可以把 mongo 放這邊
|
|
@ -0,0 +1 @@
|
|||
DROP TABLE IF EXISTS `permission`;
|
|
@ -0,0 +1,15 @@
|
|||
-- 通常會把整個表都放到記憶體當中,不常搜尋,不需要加其他搜尋的 index
|
||||
CREATE TABLE `permission`
|
||||
(
|
||||
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'PK',
|
||||
`parent` bigint unsigned DEFAULT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`http_method` varchar(255) NOT NULL,
|
||||
`http_path` text NOT NULL,
|
||||
`status` tinyint NOT NULL DEFAULT '1' COMMENT '狀態 1: 啟用, 2: 關閉',
|
||||
`type` tinyint NOT NULL DEFAULT '1' COMMENT '狀態 1: 後台, 2: 前台',
|
||||
`create_time` bigint DEFAULT 0 NOT NULL COMMENT '創建時間',
|
||||
`update_time` bigint DEFAULT 0 NOT NULL COMMENT '更新時間',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name_unique_key` (`name`)
|
||||
) ENGINE = InnoDB COMMENT ='權限表';
|
|
@ -0,0 +1 @@
|
|||
DROP DATABASE IF EXISTS `example`;
|
|
@ -0,0 +1 @@
|
|||
CREATE DATABASE IF NOT EXISTS `example`;
|
|
@ -0,0 +1,39 @@
|
|||
# migrate
|
||||
數據庫遷移工具
|
||||
|
||||
[golang-migrate](https://github.com/golang-migrate/migrate)
|
||||
|
||||
## 安裝 make
|
||||
```shell
|
||||
brew install makefile
|
||||
```
|
||||
|
||||
## 安裝 golang-migrate
|
||||
```shell
|
||||
brew install golang-migrate
|
||||
```
|
||||
|
||||
## 執行刪除 mysql schema
|
||||
|
||||
```shell
|
||||
migrate -source file://database/migrations/mysql -database 'mysql://account:password@tcp(127.0.0.1:3306)/esc_c2c' down
|
||||
```
|
||||
|
||||
## 執行安裝 mysql schema
|
||||
|
||||
```shell
|
||||
migrate -source file://database/migrations/mysql -database 'mysql://account:password@tcp(127.0.0.1:3306)/esc_c2c' up
|
||||
```
|
||||
|
||||
## 執行刪除 mongo schema
|
||||
|
||||
```shell
|
||||
migrate -source file://database/migrations/mongodb -database 'mongodb://127.0.0.1:27017/esc_c2c' down
|
||||
```
|
||||
|
||||
## 執行安裝 mongo schema
|
||||
|
||||
```shell
|
||||
migrate -source file://database/migrations/mongodb -database 'mongodb://127.0.0.1:27017/esc_c2c' up
|
||||
```
|
||||
|
|
@ -0,0 +1 @@
|
|||
DELETE FROM `role` WHERE (`role_id` = 'AM000000');
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `role` (`role_id`, `display_name`, `status`, `create_time`, `update_time`)
|
||||
VALUES ('AM000000', 'admin', 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
|
||||
('AM000001', 'visitor', 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
|
|
@ -0,0 +1,21 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package deom;
|
||||
|
||||
option go_package="./demo";
|
||||
|
||||
// OKResp
|
||||
message OKResp {}
|
||||
// NoneReq
|
||||
message NoneReq {}
|
||||
|
||||
|
||||
// DemoService ...
|
||||
service DemoService {
|
||||
// Ping ...
|
||||
rpc Ping(OKResp)returns(NoneReq);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue