Compare commits
3
Commits
1c495d3ae0
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c430a4ed86 | ||
|
|
eefb6b6b43 | ||
|
|
6eb8e379ac |
No files matched your search
+5
-3
@@ -1,6 +1,8 @@
|
||||
FROM golang:1.27.3-alpine AS builder
|
||||
FROM harbor.vitatech.com.cn:19443/vitavideo/base-golang:1.27.3-alpine AS builder
|
||||
RUN apk add --no-cache git openssh-client
|
||||
ENV GOPRIVATE=git.vitatech.com.cn
|
||||
ARG GOPROXY=https://goproxy.cn,direct
|
||||
ENV GOPROXY=${GOPROXY} \
|
||||
GOPRIVATE=git.vitatech.com.cn
|
||||
RUN git config --global url."ssh://git@git.vitatech.com.cn:12222/".insteadOf "https://git.vitatech.com.cn/" \
|
||||
&& mkdir -p -m 0700 /root/.ssh
|
||||
WORKDIR /src
|
||||
@@ -11,7 +13,7 @@ RUN --mount=type=ssh,required=true \
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 go build -mod=readonly -trimpath -o /out/api ./cmd/api
|
||||
|
||||
FROM alpine:3.23
|
||||
FROM harbor.vitatech.com.cn:19443/vitavideo/base-alpine:3.23
|
||||
RUN apk add --no-cache ca-certificates tzdata
|
||||
WORKDIR /app
|
||||
COPY --from=builder /out/api ./api
|
||||
|
||||
Vendored
+3
-3
@@ -12,7 +12,7 @@ pipeline {
|
||||
}
|
||||
environment {
|
||||
SERVICE = 'gin-api'
|
||||
IMAGE_REPOSITORY = 'harbor.vitatech.com.cn:19443/backend/gin_layout-api'
|
||||
IMAGE_REPOSITORY = 'harbor.vitatech.com.cn:19443/vitavideo/gin_layout-api'
|
||||
DOCKERFILE = 'Dockerfile'
|
||||
DEPLOY_ROOT = '/home/SHARE/devstack-scb/apps/layout-test'
|
||||
}
|
||||
@@ -29,7 +29,7 @@ pipeline {
|
||||
branches: [[name: '*/' + env.SOURCE_BRANCH]],
|
||||
userRemoteConfigs: [[
|
||||
url: 'ssh://git@git.vitatech.com.cn:12222/leo/gin_layout.git',
|
||||
credentialsId: 'gitea-layout-read'
|
||||
credentialsId: 'gitea'
|
||||
]],
|
||||
extensions: [[$class: 'CleanBeforeCheckout']]
|
||||
])
|
||||
@@ -41,7 +41,7 @@ pipeline {
|
||||
}
|
||||
stage('Build and push') {
|
||||
steps {
|
||||
sshagent(credentials: ['gitea-layout-read']) {
|
||||
sshagent(credentials: ['gitea']) {
|
||||
withCredentials([
|
||||
file(credentialsId: 'gitea-known-hosts', variable: 'GIT_KNOWN_HOSTS'),
|
||||
usernamePassword(credentialsId: 'harbor-backend',
|
||||
|
||||
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"git.vitatech.com.cn/leo/proto.git/micro_layout/client"
|
||||
|
||||
@@ -19,12 +21,38 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
healthcheckOnly := flag.Bool("healthcheck", false, "按服务配置检查健康状态并退出")
|
||||
flag.Parse()
|
||||
if *healthcheckOnly {
|
||||
if err := checkHealth(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
return
|
||||
}
|
||||
if err := run(); err != nil {
|
||||
slog.Error("application stopped", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func checkHealth() error {
|
||||
cfg, err := config.Load()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client := &http.Client{Timeout: 3 * time.Second}
|
||||
response, err := client.Get(fmt.Sprintf("http://127.0.0.1:%d/health", cfg.Server.Port))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("HTTP healthcheck returned status %d", response.StatusCode)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func run() error {
|
||||
cfg, err := config.Load()
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user