Building OPA - linux-on-ibm-z/docs GitHub Wiki
Building OPA
The instructions specify the steps to build OPA version 1.17.0 on Linux on IBM Z for following distributions:
- RHEL (8.10, 9.6, 9.7, 10.0, 10.1)
- Ubuntu (22.04, 24.04, 25.10)
General Notes:
- When following the steps below please use a standard permission user unless otherwise specified.
- A directory
/<source_root>/will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.
1. Build environment set up
Ensure that Docker-CE is installed.
Ensure the current user belongs to group docker.
2. Build using script
If you want to build OPA using manual steps, go to STEP 3.
Use the following commands to build OPA using the build script. Please make sure you have wget installed.
wget https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/OPA/1.17.0/build_opa.sh
# Build OPA
bash build_opa.sh [Provide -t option for executing build with tests]
If the build and tests complete successfully, go to STEP 6. In case of error, check logs at <source_root>/logs/ for more details or go to STEP 3 to follow manual build steps.
3. Install the system dependencies
export SOURCE_ROOT=/<source_root>/
export PATCH_URL="https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/OPA/1.17.0/patch"
-
RHEL (8.10, 9.6, 9.7, 10.0, 10.1)
sudo yum install -y gcc git make python3 python3-pip tar wget xz -
Ubuntu (22.04, 24.04, 25.10)
sudo apt-get update sudo apt-get install -y build-essential git python3 python3-pip tar wget
4. Install prerequisites
4.1. Install Go 1.26.3
cd $SOURCE_ROOT
GO_VERSION=1.26.3
wget -q https://go.dev/dl/go"${GO_VERSION}".linux-s390x.tar.gz
chmod ugo+r go"${GO_VERSION}".linux-s390x.tar.gz
sudo tar -C /usr/local -xzf go"${GO_VERSION}".linux-s390x.tar.gz
sudo ln -sf /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc # Rhel and Sles only
export PATH=$PATH:/usr/local/go/bin
go version
4.2. Install wasmtime library
cd $SOURCE_ROOT
mkdir golang-wasmtime && cd golang-wasmtime
wget https://github.com/bytecodealliance/wasmtime/releases/download/v43.0.2/wasmtime-v43.0.2-s390x-linux-c-api.tar.xz
tar xf wasmtime-v43.0.2-s390x-linux-c-api.tar.xz
sudo cp wasmtime-v43.0.2-s390x-linux-c-api/lib/libwasmtime.a /usr/lib
5. Build OPA
5.1. Build OPA from source
cd $SOURCE_ROOT
git clone -b v1.17.0 https://github.com/open-policy-agent/opa.git
cd opa
curl -sSL $PATCH_URL/opa.patch | git apply -
make build
5.2. Build OPA Docker image
cd $SOURCE_ROOT/opa
make image-s390x
5.3. Run OPA tests (Optional)
5.3.1. Run unit tests
cd $SOURCE_ROOT/opa
make test
Note:
- Several timeout tests and related failures can be addressed by re-running tests after changing the timeout value as follows:
sed -i "1855s,100,110,g" v1/runtime/runtime_test.go
6. Verify (Optional)
cd $SOURCE_ROOT/opa
./opa_linux_s390x run
Please refer to Running OPA for more information