Skip to content

Commit b851115

Browse files
Add OPAL Client EOPA build (#831)
* eopa build * 1.44.0 version for eopa - latest * Exclude pypi when prerelease * Add support for building and documenting opal-client-eopa - Updated Makefile to include new targets for building the opal-client-eopa Docker image. - Enhanced documentation to include instructions for using the eOPA variant of the OPAL Client, with a sample Docker Compose configuration. * Added expose and user under client-standalone --------- Co-authored-by: Dan Yishai <danyi1212@users.noreply.github.com>
1 parent 207c574 commit b851115

5 files changed

Lines changed: 136 additions & 1 deletion

File tree

.github/workflows/on_release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,44 @@ jobs:
217217
tags: |
218218
permitio/opal-client-cedar:${{ github.event.release.tag_name }}
219219
220+
- name: Build & Push EOPA
221+
if: ${{ github.event.release.prerelease == false }}
222+
id: build_push_eopa_regular
223+
uses: docker/build-push-action@v6
224+
with:
225+
file: docker/Dockerfile
226+
platforms: linux/amd64,linux/arm64
227+
push: true
228+
target: client-eopa
229+
cache-from: type=registry,ref=permitio/opal-client-eopa:latest
230+
cache-to: type=inline
231+
tags: |
232+
permitio/opal-client-eopa:latest
233+
permitio/opal-client-eopa:${{ github.event.release.tag_name }}
234+
235+
- name: Build & Push EOPA (prerelease)
236+
if: ${{ github.event.release.prerelease == true }}
237+
id: build_push_eopa_prerelease
238+
uses: docker/build-push-action@v6
239+
with:
240+
file: docker/Dockerfile
241+
platforms: linux/amd64,linux/arm64
242+
push: true
243+
target: client-eopa
244+
cache-from: type=registry,ref=permitio/opal-client-eopa:latest
245+
cache-to: type=inline
246+
tags: |
247+
permitio/opal-client-eopa:${{ github.event.release.tag_name }}
248+
220249
- name: Python setup
250+
if: ${{ github.event.release.prerelease == false }}
221251
uses: actions/setup-python@v5
222252
with:
223253
python-version: '3.11.8'
224254

225255
# This is the root file representing the package for all the sub-packages.
226256
- name: Bump version - packaging__.py
257+
if: ${{ github.event.release.prerelease == false }}
227258
run: |
228259
# Install required packages
229260
pip install semver packaging
@@ -244,6 +275,7 @@ jobs:
244275
cat packages/__packaging__.py
245276
246277
- name: Cleanup setup.py and Build every sub-packages
278+
if: ${{ github.event.release.prerelease == false }}
247279
run: |
248280
pip install wheel
249281
cd packages/opal-common/ ; rm -rf *.egg-info build/ dist/
@@ -258,6 +290,7 @@ jobs:
258290
259291
# Upload package distributions to the release - All assets in one step
260292
- name: Upload assets to release
293+
if: ${{ github.event.release.prerelease == false }}
261294
uses: shogo82148/actions-upload-release-asset@v1.7.5
262295
with:
263296
upload_url: ${{ github.event.release.upload_url }}
@@ -268,6 +301,7 @@ jobs:
268301
269302
# Publish package distributions to PyPI
270303
- name: Publish package distributions to PyPI - Opal-Common
304+
if: ${{ github.event.release.prerelease == false }}
271305
uses: pypa/gh-action-pypi-publish@release/v1
272306
with:
273307
password: ${{ secrets.PYPI_TOKEN }}
@@ -280,6 +314,7 @@ jobs:
280314
url: https://pypi.org/p/opal-common/
281315

282316
- name: Publish package distributions to PyPI - Opal-Client
317+
if: ${{ github.event.release.prerelease == false }}
283318
uses: pypa/gh-action-pypi-publish@release/v1
284319
with:
285320
password: ${{ secrets.PYPI_TOKEN }}
@@ -292,6 +327,7 @@ jobs:
292327
url: https://pypi.org/p/opal-client/
293328

294329
- name: Publish package distributions to PyPI - Opal-Server
330+
if: ${{ github.event.release.prerelease == false }}
295331
uses: pypa/gh-action-pypi-publish@release/v1
296332
with:
297333
password: ${{ secrets.PYPI_TOKEN }}

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ help:
1515
@echo " docker-build-server - Build opal-server Docker image"
1616
@echo " docker-run-client - Run opal-client in Docker"
1717
@echo " docker-run-server - Run opal-server in Docker"
18+
@echo " docker-build-client-eopa - Build opal-client-eopa Docker image"
1819

1920
OPAL_SERVER_URL ?= http://host.docker.internal:7002
2021
OPAL_AUTH_PRIVATE_KEY ?= /root/ssh/opal_rsa
@@ -59,6 +60,9 @@ docs-dev:
5960
docker-build-client:
6061
@docker build -t permitio/opal-client --target client -f docker/Dockerfile .
6162

63+
docker-build-client-eopa:
64+
@docker build -t permitio/opal-client-eopa --target client-eopa -f docker/Dockerfile .
65+
6266
docker-build-client-cedar:
6367
@docker build -t permitio/opal-client-cedar --target client-cedar -f docker/Dockerfile .
6468

@@ -82,11 +86,13 @@ docker-build-next:
8286
@docker build -t permitio/opal-client-standalone:next --target client-standalone -f docker/Dockerfile .
8387
@docker build -t permitio/opal-client:next --target client -f docker/Dockerfile .
8488
@docker build -t permitio/opal-server:next --target server -f docker/Dockerfile .
89+
@docker build -t permitio/opal-client-eopa:next --target client-eopa -f docker/Dockerfile .
8590

8691
docker-build-latest:
8792
@docker build -t permitio/opal-client-standalone:latest --target client-standalone -f docker/Dockerfile .
8893
@docker build -t permitio/opal-client:latest --target client -f docker/Dockerfile .
8994
@docker build -t permitio/opal-server:latest --target server -f docker/Dockerfile .
95+
@docker build -t permitio/opal-client-eopa:latest --target client-eopa -f docker/Dockerfile .
9096

9197
docker-run-server:
9298
@if [[ -z "$(OPAL_POLICY_REPO_SSH_KEY)" ]]; then \

docker/Dockerfile

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ WORKDIR /opal
8888

8989
# copy opa from official docker image
9090
ARG opa_image=openpolicyagent/opa
91-
ARG opa_tag=0.70.0-static
91+
ARG opa_tag=1.9.0-static
9292
RUN skopeo copy "docker://${opa_image}:${opa_tag}" docker-archive:./image.tar && \
9393
mkdir image && tar xf image.tar -C ./image && cat image/*.tar | tar xf - -C ./image -i && \
9494
find image/ -name "opa*" -type f -executable -print0 | xargs -0 -I "{}" cp {} ./opa && chmod 755 ./opa && \
@@ -113,6 +113,48 @@ ENV OPAL_INLINE_OPA_EXEC_PATH=/opal/opa
113113
EXPOSE 8181
114114
USER opal
115115

116+
# EOPA BINARY DOWNLOAD STAGE ------------------------
117+
# ---------------------------------------------------
118+
FROM alpine:latest AS eopa-extractor
119+
USER root
120+
121+
# Install download dependencies
122+
RUN apk add --no-cache wget
123+
124+
# Set working directory
125+
WORKDIR /download
126+
127+
# Download pre-built EOPA binary based on architecture
128+
ARG eopa_tag=v1.44.0
129+
ARG TARGETARCH
130+
RUN case "${TARGETARCH}" in \
131+
"amd64") EOPA_ARCH="x86_64" ;; \
132+
"arm64") EOPA_ARCH="arm64" ;; \
133+
*) echo "Unsupported architecture: ${TARGETARCH}" && exit 1 ;; \
134+
esac && \
135+
echo "Downloading EOPA for Linux_${EOPA_ARCH}" && \
136+
wget -O eopa "https://github.com/open-policy-agent/eopa/releases/download/${eopa_tag}/eopa_Linux_${EOPA_ARCH}" && \
137+
chmod +x eopa
138+
139+
# EOPA CLIENT IMAGE ---------------------------------
140+
# Using standalone image as base --------------------
141+
# ---------------------------------------------------
142+
FROM client-standalone AS client-eopa
143+
144+
# Temporarily move back to root for additional setup
145+
USER root
146+
147+
# copy eopa from eopa-extractor
148+
COPY --from=eopa-extractor /download/eopa ./eopa
149+
150+
# enable inline EOPA
151+
ENV OPAL_POLICY_STORE_TYPE=OPA
152+
ENV OPAL_INLINE_OPA_ENABLED=true
153+
ENV OPAL_INLINE_OPA_EXEC_PATH=/opal/eopa
154+
# expose eopa port (same as OPA)
155+
EXPOSE 8181
156+
USER opal
157+
116158
# CEDAR CLIENT IMAGE --------------------------------
117159
# Using standalone image as base --------------------
118160
# ---------------------------------------------------
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: "3.8"
2+
3+
services:
4+
broadcast_channel:
5+
image: postgres:alpine
6+
environment:
7+
- POSTGRES_DB=postgres
8+
- POSTGRES_USER=postgres
9+
- POSTGRES_PASSWORD=postgres
10+
11+
opal_server:
12+
image: permitio/opal-server:latest
13+
environment:
14+
- OPAL_BROADCAST_URI=postgres://postgres:postgres@broadcast_channel:5432/postgres
15+
- OPAL_POLICY_REPO_URL=https://github.com/permitio/opal-example-policy-repo
16+
- OPAL_POLICY_REPO_POLLING_INTERVAL=30
17+
- OPAL_DATA_CONFIG_SOURCES={"config":{"entries":[{"url":"http://opal_server:7002/policy-data","topics":["policy_data"],"dst_path":"/static"}]}}
18+
- OPAL_LOG_FORMAT_INCLUDE_PID=true
19+
ports:
20+
- "7002:7002"
21+
depends_on:
22+
- broadcast_channel
23+
24+
opal_client_eopa:
25+
image: permitio/opal-client-eopa:latest
26+
environment:
27+
- OPAL_SERVER_URL=http://opal_server:7002
28+
- OPAL_INLINE_OPA_ENABLED=true
29+
- OPAL_LOG_FORMAT_INCLUDE_PID=true
30+
- OPAL_INLINE_OPA_LOG_FORMAT=http
31+
# - OPAL_CLIENT_TOKEN=replace-me # set in production
32+
ports:
33+
- "7766:7000"
34+
- "8181:8181"
35+
depends_on:
36+
- opal_server
37+
command: sh -c "./wait-for.sh opal_server:7002 --timeout=20 -- ./start.sh"

documentation/docs/getting-started/quickstart/docker-compose-config/opal-client.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,17 @@ OPAL **listens** to policy code update notifications and **downloads up-to-date
4949

5050
OPAL **listens** to policy data update notifications and **fetches the data from the sources** specified by the instructions
5151
sent from the server. OPAL can aggregate data from multiple sources. This may include your **APIs**, **databases** and **3rd party SaaS**.
52+
53+
54+
### eOPA variant
55+
56+
OPAL Client supports running eOPA as the inline engine.
57+
58+
```yml showLineNumbers {3}
59+
service:
60+
opal_client:
61+
image: permitio/opal-client-eopa:latest
62+
```
63+
64+
See `docker/docker-compose-example-eopa.yml` for a full example. The engine exposes the same OPA-compatible HTTP API on `:8181` while OPAL keeps policies and data synchronized.
65+
Read more about eOPA [here](https://github.com/open-policy-agent/eopa).

0 commit comments

Comments
 (0)