oc-aggregator/Dockerfile

45 lines
996 B
Docker
Raw Normal View History

2025-01-15 16:25:02 +01:00
FROM golang:alpine AS deps
2025-01-15 16:25:02 +01:00
WORKDIR /app
COPY go.mod go.sum ./
RUN sed -i '/replace/d' go.mod
RUN go mod download
2025-01-15 16:25:02 +01:00
#----------------------------------------------------------------------------------------------
FROM golang:alpine AS builder
WORKDIR /app
RUN apk add git
2025-01-15 16:25:02 +01:00
RUN go install github.com/beego/bee/v2@latest
2025-01-15 16:25:02 +01:00
WORKDIR /oc-aggregator
2025-01-15 16:25:02 +01:00
COPY --from=deps /go/pkg /go/pkg
COPY --from=deps /app/go.mod /app/go.sum ./
2025-01-15 16:25:02 +01:00
RUN export CGO_ENABLED=0 && \
export GOOS=linux && \
export GOARCH=amd64 && \
export BUILD_FLAGS="-ldflags='-w -s'"
2025-01-15 16:25:02 +01:00
COPY . .
RUN sed -i '/replace/d' go.mod
RUN bee pack
RUN mkdir -p /app/extracted && tar -zxvf oc-aggregator.tar.gz -C /app/extracted
#----------------------------------------------------------------------------------------------
FROM golang:alpine
WORKDIR /app
COPY --from=builder /app/extracted/oc-aggregator /usr/bin/
COPY --from=builder /app/extracted/aggregator.json /etc/oc/aggregator.json
EXPOSE 8080
ENTRYPOINT ["oc-aggregator"]