#!/bin/bash
RUN_NAME=aicss_service
DOCKER_TAG=test
set -e

go mod tidy

# 优化编译标志
BUILD_FLAGS=(
    "-trimpath"          # 移除文件系统路径，减少二进制大小
    "-ldflags=-s -w"     # 移除符号表和调试信息，减少内存使用
)

# 使用优化的编译标志
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build "${BUILD_FLAGS[@]}"  -o output/bin/${RUN_NAME} gofly.go

echo 'build go success'

docker build -t 322814420330.dkr.ecr.ap-southeast-1.amazonaws.com/xpink/${RUN_NAME}:${DOCKER_TAG} -f Dockerfile .

docker push 322814420330.dkr.ecr.ap-southeast-1.amazonaws.com/xpink/${RUN_NAME}:${DOCKER_TAG}
