@@ -12,6 +12,16 @@ COPY ./packages/opal-server/requires.txt ./server_requires.txt
1212# install python deps
1313RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r ./base_requires.txt -r ./common_requires.txt -r ./client_requires.txt -r ./server_requires.txt
1414
15+ # CEDAR AGENT BUILD STAGE ---------------------------
16+ # split this stage to save time and reduce image size
17+ # ---------------------------------------------------
18+ FROM rust:1.69.0 as cedar-builder
19+ COPY cedar-agent /tmp/cedar-agent/
20+ ARG cargo_flags="-r"
21+ RUN cd /tmp/cedar-agent && \
22+ cargo build ${cargo_flags} && \
23+ cp /tmp/cedar-agent/target/*/cedar-agent /
24+
1525# COMMON IMAGE --------------------------------------
1626# ---------------------------------------------------
1727FROM python:3.10-slim as common
@@ -70,6 +80,8 @@ RUN mkdir -p /opal/backup
7080VOLUME /opal/backup
7181
7282
83+ # IMAGE to extract OPA from official image ----------
84+ # ---------------------------------------------------
7385FROM alpine:latest as opa-extractor
7486USER root
7587
@@ -85,7 +97,7 @@ RUN skopeo copy "docker://${opa_image}:${opa_tag}" docker-archive:./image.tar &&
8597 rm -r image image.tar
8698
8799
88- # CLIENT IMAGE ---- ----------------------------------
100+ # OPA CLIENT IMAGE ----------------------------------
89101# Using standalone image as base --------------------
90102# ---------------------------------------------------
91103FROM client-standalone as client
@@ -104,6 +116,25 @@ ENV OPAL_INLINE_OPA_ENABLED=true
104116EXPOSE 8181
105117USER opal
106118
119+ # CEDAR CLIENT IMAGE --------------------------------
120+ # Using standalone image as base --------------------
121+ # ---------------------------------------------------
122+ FROM client-standalone as client-cedar
123+
124+ # Temporarily move back to root for additional setup
125+ USER root
126+
127+ RUN apt-get update && apt-get install -y netcat jq && apt-get clean
128+
129+ # copy cedar from its build stage
130+ COPY --from=cedar-builder /cedar-agent /cedar-agent
131+
132+ # enable inline Cedar agent
133+ ENV OPAL_INLINE_CEDAR_ENABLED=true
134+ # expose cedar port
135+ EXPOSE 8180
136+ USER opal
137+
107138# SERVER IMAGE --------------------------------------
108139# ---------------------------------------------------
109140FROM common as server
0 commit comments