Compare commits

..

3 Commits

Author SHA1 Message Date
RecordingTheSmile 455b6d40de fix: update Dockerfile to include apt update before installing build-essential 2025-11-06 21:28:01 +08:00
RecordingTheSmile 62dcac103f fix: Docker构建统一使用debian镜像 2025-11-06 21:25:28 +08:00
sugarBecomer 63a83ddd5e 🐛 修改编译逻辑,安装gcc 2025-11-06 20:50:23 +08:00
2 changed files with 8 additions and 19 deletions
+6 -17
View File
@@ -1,31 +1,20 @@
FROM golang:alpine AS backend-builder
RUN apk add --no-cache build-base
FROM golang:latest AS backend-builder
RUN apt update
RUN apt install build-essential
WORKDIR /build
COPY . .
ENV CGO_ENABLED=1
RUN go build -ldflags="-s -w" -o bin/server
RUN apk add --no-cache upx
RUN apt install upx-ucl
RUN upx --best --lzma bin/server
# 使用更小的 Debian
FROM debian:bookworm-slim
# 安装最小运行时依赖
RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
FROM golang:latest
COPY --from=backend-builder /build/bin/server /app/server
COPY static /app/static
COPY static/*.so /app/
WORKDIR /app
# 确保文件存在且有执行权限
RUN ls -la /app/ && \
chmod +x /app/server && \
echo "=== 依赖检查 ===" && \
ldd /app/server || echo "无法检查依赖"
ENV LD_LIBRARY_PATH=/app
EXPOSE 8080
RUN ls -a
CMD ["/app/server"]
CMD ["./server"]
+2 -2
View File
@@ -50,7 +50,7 @@ func Pass(err *error) {
if r := recover(); r != nil {
e, ok := errorx.ErrorFromPanic(r)
if ok {
*err = e
*err = oops.Wrap(e)
} else {
panic(r)
}
@@ -61,7 +61,7 @@ func HandleError(f func(error)) {
if r := recover(); r != nil {
e, ok := errorx.ErrorFromPanic(r)
if ok {
f(e)
f(oops.Wrap(e))
} else {
panic(r)
}