initial commit

This commit is contained in:
Jiao77
2026-03-01 09:13:24 +08:00
commit 72baa341cc
43 changed files with 12560 additions and 0 deletions

43
server/Dockerfile Normal file
View File

@@ -0,0 +1,43 @@
# 构建阶段
FROM golang:1.21-alpine AS builder
WORKDIR /app
# 安装依赖
RUN apk add --no-cache git gcc musl-dev
# 复制 go.mod 和 go.sum
COPY go.mod go.sum ./
# 下载依赖
RUN go mod download
# 复制源代码
COPY . .
# 构建二进制文件
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o novablog-server ./cmd/server
# 运行阶段
FROM alpine:latest
WORKDIR /app
# 安装 ca-certificates用于 HTTPS 请求)
RUN apk --no-cache add ca-certificates tzdata
# 从构建阶段复制二进制文件
COPY --from=builder /app/novablog-server .
# 创建数据目录
RUN mkdir -p /app/data
# 暴露端口
EXPOSE 8080
# 设置环境变量
ENV GIN_MODE=release
ENV DB_PATH=/app/data/novablog.db
# 运行
CMD ["./novablog-server"]