Skip to content

Commit

Permalink
Dockerify the batching demo (#7)
Browse files Browse the repository at this point in the history
* Run npm audit fix --force

* Dockerify the demo

* Update readme

* Reword
  • Loading branch information
chendrix authored Jul 17, 2024
1 parent ba9db4b commit e8f8f53
Show file tree
Hide file tree
Showing 5 changed files with 437 additions and 334 deletions.
15 changes: 15 additions & 0 deletions opa-react-demo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:22

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install

# Bundle app source
COPY . /usr/src/app

EXPOSE 3000
CMD [ "npm", "start" ]
20 changes: 13 additions & 7 deletions opa-react-demo/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# `@styra/opa-react` Demos

This React application is show-casing specific features of `@styra/opa-react`.
This React application showcases the request batching feature of `@styra/opa-react` when used with the [Enterprise OPA Batch API](https://docs.styra.com/enterprise-opa/reference/api-reference/batch-api).

Currently, it includes a demo of batching requests when used with [Enterprise OPA](https://docs.styra.com/enterprise-opa), or a custom implemetation of its [Batch API](https://docs.styra.com/enterprise-opa/reference/api-reference/batch-api).
## How to use

### Docker

## How to use
1. Set `$EOPA_LICENSE_KEY`
1. Run `docker compose up`
1. Go to <http://127.0.0.1:3000>

1. Download and start Enterprise OPA with the `policies` loaded: `eopa run --log-level debug --server policies/`
2. Start the app: `npm install && npm run start`
3. Go to http://127.0.0.1:3000
### Binaries

1. [Download Enterprise OPA](https://docs.styra.com/enterprise-opa/how-to/install/local)
1. Set `$EOPA_LICENSE_KEY` or sign up for a trial by running `eopa license trial`
1. Start Enterprise OPA with the `policies` loaded: `eopa run --log-level debug --server policies/`
1. Start the app: `npm install && npm run start`
1. Go to <http://127.0.0.1:3000>

## Note on using OPA

You can use the demo apps with OPA. The only thing that won't work is enabling batching.
You can use the demo app with the open source Open Policy Agent, however batching mode will not work.
29 changes: 29 additions & 0 deletions opa-react-demo/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
services:
react-demo:
build: .
expose:
- 3000
depends_on:
- eopa
command:
- npm
- start
network_mode: host

eopa:
image: ghcr.io/styrainc/enterprise-opa:latest
expose:
- 8181
ports:
- "8181:8181"
command:
- run
- --server
- --addr=:8181
- --log-level=debug
- /policies
working_dir: /
volumes:
- ./policies:/policies
environment:
EOPA_LICENSE_KEY: ${EOPA_LICENSE_KEY}
Loading

0 comments on commit e8f8f53

Please sign in to comment.