chore: update Dockerfile and docker-compose for Kratos binary
This commit is contained in:
parent
42addaea7d
commit
80507c0e18
34
Dockerfile
34
Dockerfile
@ -1,36 +1,14 @@
|
|||||||
# Build Stage - 使用预装 Go 的基础镜像
|
|
||||||
FROM golang:1.25-alpine AS builder
|
FROM golang:1.25-alpine AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
ENV GOPROXY=https://goproxy.cn,direct
|
|
||||||
ENV GOSUMDB=sum.golang.google.cn
|
|
||||||
|
|
||||||
# 复制依赖文件
|
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
# 复制源代码
|
|
||||||
COPY . .
|
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
|
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
|
WORKDIR /app
|
||||||
|
EXPOSE 8080 9000
|
||||||
RUN apk add --no-cache wget file
|
CMD ["/bin/file-system", "-conf", "configs/config.yaml"]
|
||||||
|
|
||||||
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"]
|
|
||||||
|
|||||||
@ -1,34 +1,22 @@
|
|||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
file-system-server:
|
file-system:
|
||||||
image: 192.168.1.154:31010/docker/file-system-server:latest
|
build: .
|
||||||
container_name: file-system-server
|
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
restart: unless-stopped
|
- "9000:9000"
|
||||||
environment:
|
environment:
|
||||||
- GIN_MODE=release
|
- RUSTFS_ACCESS_KEY_ID=${RUSTFS_ACCESS_KEY_ID}
|
||||||
- RUSTFS_ENDPOINT_URL=http://192.168.1.154:9000
|
- RUSTFS_SECRET_ACCESS_KEY=${RUSTFS_SECRET_ACCESS_KEY}
|
||||||
- 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
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./logs:/app/logs
|
- ./configs/config.yaml:/app/configs/config.yaml
|
||||||
networks:
|
depends_on:
|
||||||
- app-network
|
- postgres
|
||||||
|
postgres:
|
||||||
networks:
|
image: postgres:16-alpine
|
||||||
app-network:
|
environment:
|
||||||
driver: bridge
|
POSTGRES_DB: file_system
|
||||||
|
POSTGRES_USER: postgres
|
||||||
volumes:
|
POSTGRES_PASSWORD: postgres
|
||||||
logs:
|
ports:
|
||||||
driver: local
|
- "5432:5432"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user