blob: 2905d771778857131ae32b4ae59a7abad53f2396 [file] [log] [blame]
gururajarao79542b9d12024-11-22 14:28:41 +01001FROM curlimages/curl:7.78.0 AS build
2
3# Get OPA
4RUN curl -Lo /tmp/opa https://github.com/open-policy-agent/opa/releases/download/v0.69.0/opa_linux_amd64
5
6FROM golang:1.23 AS compile
7
8RUN mkdir /app
9
10COPY ../go.mod ../go.sum /app/
11
12COPY . .
13
14RUN mkdir /app/cfg
15ADD ../cfg /app/cfg
16
17RUN mkdir /app/consts
18ADD ../consts /app/consts
19
20RUN mkdir /app/api
21ADD ../api /app/api
22
23RUN mkdir /app/cmd
24ADD ../cmd /app/cmd
25
26RUN mkdir /app/pkg
27ADD ../pkg /app/pkg
28
29RUN mkdir /app/bundles
30
31WORKDIR /app
32
33# Build the binary
34RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /app/opa-pdp /app/cmd/opa-pdp/opa-pdp.go
35#COPY config.json /app/config.json
36#RUN chmod 644 /app/config.json
37
38FROM ubuntu
39
40RUN apt-get update && apt-get install -y netcat-openbsd && rm -rf /var/lib/apt/lists/*
41
42RUN apt-get update && apt-get install -y curl
43
44# Copy our static executable from compile stage
45RUN mkdir /app
46COPY --from=compile /app /app
47RUN chmod +x /app/opa-pdp
48
49# Copy our opa executable from build stage
50COPY --from=build /tmp/opa /app/opa
51RUN chmod 755 /app/opa
52
53WORKDIR /app
54EXPOSE 8282
55
56# Command to run OPA with the policies
57CMD ["/app/opa-pdp"]
58