From 1607aef1f1919fed73e28027d77aa4f7ed7c0879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E5=8F=AF?= Date: Sat, 8 Oct 2022 14:05:33 +0800 Subject: [PATCH] feat: support upload docker image to ghci (#38) --- .github/workflows/goreleaser.yml | 31 ++++++++- .github/workflows/latest.yml | 31 ++++++++- .goreleaser.yml | 26 +++---- Dockerfile | 7 ++ config/config.toml | 112 +++++++++++++++---------------- 5 files changed, 135 insertions(+), 72 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index 704a17e..fe9c0e9 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -5,6 +5,10 @@ on: tags: - "v**" +env: + REGISTRY: ghcr.io + IMAGE_NAME: juno-agent + jobs: goreleaser: runs-on: ubuntu-latest @@ -31,6 +35,29 @@ jobs: # either 'goreleaser' (default) or 'goreleaser-pro' distribution: goreleaser version: latest - args: release --rm-dist + args: release env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Log in to the Container registry + uses: docker/login-action@v1.10.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: image_name + run: echo ${{ env.IMAGE_NAME }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3.6.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: mr-smithers-excellent/docker-build-push@v5.6 + with: + registry: ${{ env.REGISTRY }} + image: ${{ env.IMAGE_NAME }} + addLatest: true + dockerfile: Dockerfile + username: ${{ secrets.GHCR_USERNAME }} + password: ${{ secrets.GHCR_TOKEN }} diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml index cc3912d..79b55e7 100644 --- a/.github/workflows/latest.yml +++ b/.github/workflows/latest.yml @@ -3,7 +3,11 @@ name: goreleaser on: push: branches: - - master + - "*" + +env: + REGISTRY: ghcr.io + IMAGE_NAME: juno-agent jobs: goreleaser: @@ -31,10 +35,33 @@ jobs: # either 'goreleaser' (default) or 'goreleaser-pro' distribution: goreleaser version: latest - args: release --rm-dist + args: release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: actions/upload-artifact@v2 with: name: my-artifact path: dist/*_linux_amd64.tar.gz + - name: Log in to the Container registry + uses: docker/login-action@v1.10.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: image_name + run: echo ${{ env.IMAGE_NAME }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3.6.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: mr-smithers-excellent/docker-build-push@v5.6 + with: + registry: ${{ env.REGISTRY }} + image: ${{ env.IMAGE_NAME }} + addLatest: false + dockerfile: Dockerfile + username: ${{ secrets.GHCR_USERNAME }} + password: ${{ secrets.GHCR_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 4f5c00c..732ef78 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,15 +1,17 @@ project_name: juno-agent builds: -- main: ./cmd/juno-agent - id: "juno-agent" - binary: juno-agent - goos: - - linux - - darwin - - windows - goarch: [amd64] - ldflags: - - -X github.com/douyu/jupiter/pkg.buildAppVersion={{.Version}} - - -X github.com/douyu/jupiter/pkg.buildTime={{.Date}} - - -X github.com/douyu/jupiter/pkg.buildUser=goreleaser \ No newline at end of file + - main: ./cmd/juno-agent + id: juno-agent + binary: juno-agent + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: [amd64] + ldflags: + - -X github.com/douyu/jupiter/pkg.buildAppVersion={{.Version}} + - -X github.com/douyu/jupiter/pkg.buildTime={{.Date}} + - -X github.com/douyu/jupiter/pkg.buildUser=goreleaser diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d086301 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM alpine:latest + +WORKDIR /app +COPY dist/juno-agent_linux_amd64_v1/juno-agent /app/bin/ +COPY config /app/config + +CMD ["/app/bin/juno-agent", "--config", "/app/config/config.toml"] diff --git a/config/config.toml b/config/config.toml index 79816a3..17ed3c3 100644 --- a/config/config.toml +++ b/config/config.toml @@ -1,91 +1,91 @@ [plugin] -[plugin.regProxy] -enable = true + [plugin.regProxy] + enable = true -[plugin.regProxy.prometheus] -enable = true -path = "/home/www/system/prometheus/conf" -enableZone = true -zones = ["HB-WHYL"] # 用于支持zone过滤 -enableCleanup = true -timeInterval = 10 + [plugin.regProxy.prometheus] + enable = true + path = "/home/www/system/prometheus/conf" + enableZone = true + zones = ["HB-WHYL"] # 用于支持zone过滤 + enableCleanup = false + timeInterval = 10 [plugin.confProxy] -# 配置中心地址 -env = ["dev", "live", "pre"] -prefix = "/juno-agent" -timeout = "3s" -enable = true - -#配置中心数据源 -[plugin.confProxy.mysql] -enable = false -dsn = "" -secure = false + # 配置中心地址 + env = ["dev", "live", "pre"] + prefix = "/juno-agent" + timeout = "3s" + enable = true + + #配置中心数据源 + [plugin.confProxy.mysql] + enable = false + dsn = "" + secure = false [plugin.supervisor] -enable = true -dir = "/etc/supervisor/conf.d" + enable = true + dir = "/etc/supervisor/conf.d" [plugin.systemd] -enable = true -dir = "/etc/systemd/system" + enable = true + dir = "/etc/systemd/system" [plugin.nginx] -enable = false -dir = "/usr/local/openresty/nginx/conf" + enable = false + dir = "/usr/local/openresty/nginx/conf" [plugin.report] -enable = true -debug = true -addr = "http://127.0.0.1:50000/api/v1/resource/node/heartbeat" -internal = "60s" -hostName = "JUNO_HOST" # 环境变量的名称,或者命令行参数的名称 -regionCode = "REGION_CODE" # 环境变量的名称,或者命令行参数的名称 -regionName = "REGION_NAME" -zoneCode = "ZONE_CODE" -zoneName = "ZONE_NAME" -env = "ENV" + enable = true + debug = true + addr = "http://127.0.0.1:50002/api/v1/resource/node/heartbeat" + internal = "60s" + hostName = "JUNO_HOST" # 环境变量的名称,或者命令行参数的名称 + regionCode = "REGION_CODE" # 环境变量的名称,或者命令行参数的名称 + regionName = "REGION_NAME" + zoneCode = "ZONE_CODE" + zoneName = "ZONE_NAME" + env = "ENV" [plugin.healthCheck] -enable = false + enable = false [plugin.process] -enable = false + enable = false [plugin.worker] -enable = false -reqTimeout = 10 + enable = false + reqTimeout = 10 # service registry etcd [jupiter.etcdv3.register] -endpoints = ["etcd-naming.dz11.com:2379"] -connectTimeout = "10s" + endpoints = ["http://127.0.0.1:2379"] + connectTimeout = "3s" # default etcd (config-publish / cronjob-dispatch / etc...) [jupiter.etcdv3.default] -endpoints = ["etcd-naming.dz11.com:2379"] -connectTimeout = "10s" + endpoints = ["http://127.0.0.1:2379"] + connectTimeout = "3s" [jupiter.logger.default] -name = "default" -debug = true + name = "default" + debug = true [jupiter.logger.cronjob] -name = "cronjob.log" -level = "debug" + name = "cronjob.log" + level = "debug" [jupiter.server] -[jupiter.server.grpc] -host = "0.0.0.0" -port = 60813 + [jupiter.server.grpc] + host = "0.0.0.0" + port = 60813 -[jupiter.server.http] -host = "0.0.0.0" -port = 50010 + [jupiter.server.http] + host = "0.0.0.0" + port = 50010 [api] -# 密钥长度需要为32位 -secret = "j1Sblr5uiJtuCQLsT89BRqtAgWDO2anI" + # 密钥长度需要为32位 + secret = "j1Sblr5uiJtuCQLsT89BRqtAgWDO2anI"