From 542b9d143da57bcb3894f730c9ca2200aa7b89cb Mon Sep 17 00:00:00 2001 From: gururajarao79 Date: Fri, 22 Nov 2024 14:28:41 +0100 Subject: phase1 opa pdp changes For details on scope and implementation, please check. https://lf-onap.atlassian.net/wiki/spaces/DW/pages/51150925/OPA+PDP Code Coverage Total: 70.8% Issue-ID: POLICY-5156 Change-Id: Ied07ee1596e9f447183fb715baaa68c704a9fe99 Signed-off-by: gururajarao79 --- build/Dockerfile | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 build/Dockerfile (limited to 'build/Dockerfile') diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..2905d77 --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,58 @@ +FROM curlimages/curl:7.78.0 AS build + +# Get OPA +RUN curl -Lo /tmp/opa https://github.com/open-policy-agent/opa/releases/download/v0.69.0/opa_linux_amd64 + +FROM golang:1.23 AS compile + +RUN mkdir /app + +COPY ../go.mod ../go.sum /app/ + +COPY . . + +RUN mkdir /app/cfg +ADD ../cfg /app/cfg + +RUN mkdir /app/consts +ADD ../consts /app/consts + +RUN mkdir /app/api +ADD ../api /app/api + +RUN mkdir /app/cmd +ADD ../cmd /app/cmd + +RUN mkdir /app/pkg +ADD ../pkg /app/pkg + +RUN mkdir /app/bundles + +WORKDIR /app + +# Build the binary +RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /app/opa-pdp /app/cmd/opa-pdp/opa-pdp.go +#COPY config.json /app/config.json +#RUN chmod 644 /app/config.json + +FROM ubuntu + +RUN apt-get update && apt-get install -y netcat-openbsd && rm -rf /var/lib/apt/lists/* + +RUN apt-get update && apt-get install -y curl + +# Copy our static executable from compile stage +RUN mkdir /app +COPY --from=compile /app /app +RUN chmod +x /app/opa-pdp + +# Copy our opa executable from build stage +COPY --from=build /tmp/opa /app/opa +RUN chmod 755 /app/opa + +WORKDIR /app +EXPOSE 8282 + +# Command to run OPA with the policies +CMD ["/app/opa-pdp"] + -- cgit 1.2.3-korg