oc-discovery/Dockerfile

47 lines
1.1 KiB
Docker
Raw Normal View History

2025-01-15 16:32:12 +01:00
FROM golang:alpine AS deps
2023-03-09 11:45:29 +01:00
2025-01-15 16:32:12 +01:00
WORKDIR /app
COPY go.mod go.sum ./
RUN sed -i '/replace/d' go.mod
RUN go mod download
2023-03-09 11:45:29 +01:00
2025-01-15 16:32:12 +01:00
#----------------------------------------------------------------------------------------------
FROM golang:alpine AS builder
WORKDIR /app
2023-03-09 11:45:29 +01:00
RUN apk add git
2025-01-15 16:32:12 +01:00
RUN go install github.com/beego/bee/v2@latest
2023-10-18 15:24:57 +02:00
2025-01-15 16:32:12 +01:00
WORKDIR /oc-discovery
2023-10-18 15:24:57 +02:00
2025-01-15 16:32:12 +01:00
COPY --from=deps /go/pkg /go/pkg
COPY --from=deps /app/go.mod /app/go.sum ./
2023-10-18 15:24:57 +02:00
2025-01-15 16:32:12 +01:00
RUN export CGO_ENABLED=0 && \
export GOOS=linux && \
export GOARCH=amd64 && \
export BUILD_FLAGS="-ldflags='-w -s'"
2023-03-09 11:45:29 +01:00
2025-01-15 16:32:12 +01:00
COPY . .
2023-03-09 11:45:29 +01:00
2025-01-15 16:32:12 +01:00
RUN sed -i '/replace/d' go.mod
RUN bee pack
RUN mkdir -p /app/extracted && tar -zxvf oc-discovery.tar.gz -C /app/extracted
#RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' /app/extracted/swagger/index.html
2023-03-09 11:45:29 +01:00
2025-01-15 16:32:12 +01:00
#----------------------------------------------------------------------------------------------
2023-03-09 11:45:29 +01:00
2025-01-15 16:32:12 +01:00
FROM golang:alpine
WORKDIR /app
COPY --from=builder /app/extracted/oc-discovery /usr/bin/
#COPY --from=builder /app/extracted/swagger /app/swagger
COPY --from=builder /app/extracted/docker_discovery.json /etc/oc/discovery.json
2023-03-09 11:45:29 +01:00
EXPOSE 8080
ENTRYPOINT ["oc-discovery"]