Files
huangjin fe3ad20fe2 'init'
2026-06-29 17:34:59 +08:00

29 lines
608 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 编译 Go 后端到 Linux amd64
# 使用方式:./build.sh
set -e
cd "$(dirname "$0")"
OUTPUT="server"
BIN_DIR="bin"
echo "=== 编译 Go 后端Linux amd64==="
# 设置交叉编译环境
export GOOS=linux
export GOARCH=amd64
export CGO_ENABLED=0
go build -ldflags="-s -w" -o "${BIN_DIR}/${OUTPUT}" ./cmd/server/
echo "=== 编译完成 ==="
echo "输出文件:${BIN_DIR}/${OUTPUT}"
file "${BIN_DIR}/${OUTPUT}"
# 复制配置文件
cp config/config-prod.yaml "${BIN_DIR}/" 2>/dev/null || echo "注意config-prod.yaml 不存在"
echo "=== 部署文件 ==="
ls -lh "${BIN_DIR}/"