chore: update Dockerfile and docker-compose for Kratos binary

This commit is contained in:
向宁 2026-05-25 13:13:00 +08:00
parent 42addaea7d
commit 80507c0e18
2 changed files with 22 additions and 56 deletions

View File

@ -1,36 +1,14 @@
# Build Stage - 使用预装 Go 的基础镜像
FROM golang:1.25-alpine AS builder
WORKDIR /app
ENV GOPROXY=https://goproxy.cn,direct
ENV GOSUMDB=sum.golang.google.cn
# 复制依赖文件
COPY go.mod go.sum ./
RUN go mod download
# 复制源代码
COPY . .
RUN CGO_ENABLED=0 go build -o /bin/file-system ./cmd/server
# 编译 Go 应用
RUN go build -v -o server ./cmd/server
# Run Stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /bin/file-system /bin/file-system
COPY configs/config.yaml /app/configs/config.yaml
WORKDIR /app
RUN apk add --no-cache wget file
COPY --from=builder /app/server .
RUN chmod +x server
COPY --from=builder /app/docs ./docs
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
CMD ["./server"]
EXPOSE 8080 9000
CMD ["/bin/file-system", "-conf", "configs/config.yaml"]

View File

@ -1,34 +1,22 @@
version: '3.8'
services:
file-system-server:
image: 192.168.1.154:31010/docker/file-system-server:latest
container_name: file-system-server
file-system:
build: .
ports:
- "8080:8080"
restart: unless-stopped
- "9000:9000"
environment:
- GIN_MODE=release
- RUSTFS_ENDPOINT_URL=http://192.168.1.154:9000
- RUSTFS_ACCESS_KEY_ID=rustfsadmin
- RUSTFS_SECRET_ACCESS_KEY=rustfsadmin123
- RUSTFS_REGION=us-east-1
- AUTH_API_KEY=rustfsadmin123
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/swagger/index.html"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
- RUSTFS_ACCESS_KEY_ID=${RUSTFS_ACCESS_KEY_ID}
- RUSTFS_SECRET_ACCESS_KEY=${RUSTFS_SECRET_ACCESS_KEY}
volumes:
- ./logs:/app/logs
networks:
- app-network
networks:
app-network:
driver: bridge
volumes:
logs:
driver: local
- ./configs/config.yaml:/app/configs/config.yaml
depends_on:
- postgres
postgres:
image: postgres:16-alpine
environment:
POSTGRES_DB: file_system
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"