Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangshuai1171 committed Apr 19, 2022
1 parent 51be214 commit 11e5264
Show file tree
Hide file tree
Showing 266 changed files with 10,128 additions and 18,513 deletions.
70 changes: 0 additions & 70 deletions .conf-struct.yml

This file was deleted.

45 changes: 20 additions & 25 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
# Log Proxy
IS_LOG_LOG_PROXY_HOST=192.168.2.80
IS_LOG_LOG_PROXY_PORT=6381
# Redis
IS_REDIS_NODES="192.168.2.80:9001 192.168.2.80:9002 192.168.2.80:9003"
IS_GATEWAY_NERVS_ENABLED=false
IS_GATEWAY_NERVS_ENDPOINT=""
# Mysql
IS_MYSQL_DSN=root:123456@tcp(192.168.2.80:3306)/cap?charset=utf8mb4&parseTime=True&loc=Local
# Influxdb
IS_INFLUXDB_ENABLED=false
IS_INFLUXDB_ADDRESS=
IS_INFLUXDB_PORT=
IS_INFLUXDB_DATABASE=
IS_INFLUXDB_USERNAME=
IS_INFLUXDB_PASSWORD=
# Keymanager
IS_KEYMANAGER_UPPER_CA=
IS_INFLUXDB_ENABLED: true
IS_INFLUXDB_ADDRESS: 127.0.0.1
IS_INFLUXDB_DATABASE: victoria
IS_INFLUXDB_PASSWORD: victoria
IS_INFLUXDB_PORT: "8427"
IS_INFLUXDB_READ_PASSWORD: victoria
IS_INFLUXDB_READ_USERNAME: victoria
IS_INFLUXDB_USERNAME: victoria
IS_KEYMANAGER_SELF_SIGN=false
IS_CSR_TEMPLATES_INTERMEDIATE_CA_O=
IS_CSR_TEMPLATES_INTERMEDIATE_CA_OU=
IS_CSR_TEMPLATES_INTERMEDIATE_CA_EXPIRY=175200h
IS_CSR_TEMPLATES_ROOT_CA_O="CI123 ROOT AUTHORITY"
IS_CSR_TEMPLATES_ROOT_CA_EXPIRY=175200h
# HTTP
IS_HTTP_CA_LISTEN=0.0.0.0:8081
IS_KEYMANAGER_CSR_TEMPLATES_INTERMEDIATE_CA_O: site s105 huawei-shanghai-105
IS_KEYMANAGER_CSR_TEMPLATES_INTERMEDIATE_CA_OU: spiffe://spiffeid/cluster
IS_KEYMANAGER_UPPER_CA: https://rootca-tls:8081
IS_LOG_LOG_PROXY_HOST: redis-host
IS_LOG_LOG_PROXY_PORT: 6379
IS_MYSQL_DSN: root:root@tcp(127.0.0.1:3306)/cap?charset=utf8mb4&parseTime=True&loc=Local
IS_OCSP_CACHE_TIME: 60
IS_SINGLECA_CONFIG_PATH: /etc/capitalizone/config.json
IS_VAULT_ADDR: http://127.0.0.1:8200
IS_VAULT_ENABLED: "false"
IS_VAULT_INIT: "true"
IS_VAULT_PREFIX: ca/
18 changes: 0 additions & 18 deletions .env.prod

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
# IDE configs
.idea
.vscode
./bin
12 changes: 0 additions & 12 deletions .gitlab-ci.yml

This file was deleted.

20 changes: 13 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
FROM hub.oneitfarm.com/library/golang:1.17.8-alpine AS builder
FROM golang:1.17.8-alpine AS builder

ENV GO111MODULE=on \
GOPROXY=https://goproxy.oneitfarm.com,https://goproxy.cn,direct

WORKDIR /build

COPY . .
RUN CGO_ENABLED=0 go build -o capitalizone .
RUN CGO_ENABLED=0 go build -o zaca .

FROM harbor.oneitfarm.com/bifrost/ubuntu:20.04
FROM ubuntu:20.04

WORKDIR /capitalizone
WORKDIR /zaca

COPY --from=builder /build/capitalizone .
COPY --from=builder /build/zaca .
COPY --from=builder /build/database/mysql/migrations ./database/mysql/migrations
COPY --from=builder /build/conf.default.yml .
COPY --from=builder /build/conf.prod.yml .
COPY --from=builder /build/conf.test.yml .
RUN chmod +x capitalizone

CMD ["./capitalizone", "http"]
# API service
CMD ["./zaca", "api"]

# TLS service
# CMD ["./zaca", "api"]

# OCSP service
# CMD ["./zaca", "api"]
22 changes: 6 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
.PHONY: all build clean

GOPROXY=https://goproxy.oneitfarm.com,https://goproxy.cn,direct
PROG=bin/capitalizone
PROG=bin/zaca
SRCS=.

# git commit hash
COMMIT_HASH=$(shell git rev-parse --short HEAD || echo "GitNotFound")
# 编译日期
# Compilation date
BUILD_DATE=$(shell date '+%Y-%m-%d %H:%M:%S')
# 编译条件
# Compilation conditions
CFLAGS = -ldflags "-s -w -X \"main.BuildVersion=${COMMIT_HASH}\" -X \"main.BuildDate=$(BUILD_DATE)\""

all:
if [ ! -d "./bin/" ]; then \
mkdir bin; \
fi
GOPROXY=$(GOPROXY) CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(CFLAGS) -o $(PROG) $(SRCS)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(CFLAGS) -o $(PROG) $(SRCS)

build:
go build -race -tags=jsoniter
Expand All @@ -33,19 +32,10 @@ test:
go run main.go -env test

rootca:
go run main.go -env test -envfile ".env.rootca" -rootca

fake:
go run test/fake/fake_server.go -env test -ca https://192.168.2.80:8381

cfssl-model:
gen --sqltype=mysql -c "root:123456@tcp(192.168.2.80:3306)/cap?charset=utf8mb4&parseTime=True&loc=Local" -d cap --json --generate-dao --overwrite --gorm --db --module "gitlab.oneitfarm.com/bifrost/capitalizone/examples/cfssl-model" --out ./examples/cfssl-model

telegraf:
sudo docker run --network=host -v `pwd`/telegraf.conf:/telegraf.conf --rm -it telegraf:1.19.0 telegraf --config /telegraf.conf
go run main.go -env test -envfile ".env.example" -rootca

migration:
go run main.go -envfile ".env.prod"
go run main.go -envfile ".env.example"

clean:
rm -rf ./bin
Loading

0 comments on commit 11e5264

Please sign in to comment.