33 lines
849 B
Docker
33 lines
849 B
Docker
FROM golang:1.24-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
ENV GOPROXY=https://goproxy.cn,direct
|
|
ENV GOPRIVATE=git.yoresee.cc/YoreseeDoc
|
|
|
|
COPY backend/go.mod backend/go.sum ./backend/
|
|
COPY backend ./backend
|
|
|
|
WORKDIR /app/backend
|
|
|
|
RUN go mod download
|
|
RUN go mod tidy
|
|
RUN CGO_ENABLED=0 go build -p 1 -o main.out cmd/main.go && \
|
|
CGO_ENABLED=0 go build -p 1 -o migrate.out ./cmd/migrate && \
|
|
CGO_ENABLED=0 go build -p 1 -o db_init.out ./cmd/db_init && \
|
|
CGO_ENABLED=0 go build -p 1 -o es_init.out ./cmd/es_init
|
|
|
|
FROM alpine:latest AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /app/backend/main.out .
|
|
COPY --from=builder /app/backend/migrate.out .
|
|
COPY --from=builder /app/backend/db_init.out .
|
|
COPY --from=builder /app/backend/es_init.out .
|
|
|
|
EXPOSE 8080
|
|
EXPOSE 9090
|
|
|
|
CMD ["sh", "-c", "./migrate.out && ./db_init.out && ./es_init.out && ./main.out"]
|