This document describes the folder layout and how to extend it.
opa-project/
├── docker-compose.yml # Run OPA with policies mounted
├── policies/ # Rego policy files (all loaded automatically)
│ ├── policy.rego # authz package
│ └── rbac.rego # rbac package
├── scripts/ # Helper scripts
│ └── run-project.sh
└── docs/ # Documentation
├── project-structure.md
└── run-and-test-with-postman.md
| Folder / file | Purpose |
|---|---|
| policies/ | All .rego files live here. Add more files (e.g. rbac.rego, org.rego) and load them via bundle or multiple run arguments. Keeps policy code separate from tooling. |
| scripts/ | One-off or helper scripts (run, build, test). Keeps the repo root clean. |
| docs/ | Guides and references. |
| docker-compose.yml | At root so docker compose works from the project root without extra config. |
- Add new
.regofiles underpolicies/(e.g.policies/org.rego). - OPA loads the whole
policies/directory, so new files are picked up automatically. - Restart:
docker compose down && docker compose up -d. - Query via
POST /v1/data/<package>/<rule>— the package name matches thepackagedeclaration in your.regofile.
- tests/ or policies/*_test.rego — OPA test files (
opa test policies/). - data/ — Static JSON/YAML that policies reference (e.g. role mappings), loaded via
--dataor bundle. - .opa/ or config.yaml — OPA config for discovery, caching, etc., when you need it.
For a single policy and Docker-based run, the current structure is enough; add the above when you introduce more policies or automation.