-
Notifications
You must be signed in to change notification settings - Fork 56
Building OPA
The instructions specify the steps to build OPA version 0.69.0 on Linux on IBM Z for following distributions:
- RHEL (8.8, 8.10, 9.2, 9.4)
- SLES (15 SP5, 15 SP6)
- Ubuntu (20.04, 22.04, 24.04)
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.
Ensure that Docker-CE is installed.
Ensure the current user belongs to group docker
.
Use the below command to add group docker
if it does not exist:
sudo groupadd docker
Use the below command to add current user to group docker
if it has not been done:
sudo usermod -aG docker $USER && newgrp docker
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/0.69.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.
export SOURCE_ROOT=/<source_root>/
export PATCH_URL=https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/OPA/0.69.0/patch
-
RHEL (8.8, 8.10, 9.2, 9.4)
sudo yum install -y gcc git make python3 python3-pip tar wget
-
SLES (15 SP5, 15 SP6)
sudo zypper refresh sudo zypper install -y gcc git make python3 python3-pip tar wget awk hostname
-
Ubuntu (20.04, 22.04, 24.04)
sudo apt-get update sudo apt-get install -y gcc git make python3 python3-pip tar wget
GO_VERSION=1.23.1
wget -q https://storage.googleapis.com/golang/go"${GO_VERSION}".linux-s390x.tar.gz
chmod ugo+r go"${GO_VERSION}".linux-s390x.tar.gz
sudo rm -rf /usr/local/go /usr/bin/go
sudo tar -C /usr/local -xzf go"${GO_VERSION}".linux-s390x.tar.gz
sudo ln -sf /usr/local/go/bin/go /usr/bin/
sudo ln -sf /usr/local/go/bin/gofmt /usr/bin/
sudo ln -sf /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc # Rhel and Sles only
go version
cd $SOURCE_ROOT
mkdir golang-wasmtime && cd golang-wasmtime
wget https://github.com/bytecodealliance/wasmtime/releases/download/v3.0.1/wasmtime-v3.0.1-s390x-linux-c-api.tar.xz
tar xf wasmtime-v3.0.1-s390x-linux-c-api.tar.xz
sudo cp wasmtime-v3.0.1-s390x-linux-c-api/lib/libwasmtime.a /usr/lib
# Build toolchain image
wget $PATCH_URL/golang-wasmtime.Dockerfile
docker build -t golang-wasmtime:1.23.1-bookworm -f ./golang-wasmtime.Dockerfile .
cd $SOURCE_ROOT
wget $PATCH_URL/opa.diff
git clone -b v0.69.0 https://github.com/open-policy-agent/opa.git
cd opa
git apply --ignore-whitespace ../opa.diff
make ci-go-ci-build-linux # For RHEL 9.x, Ubuntu (22.04, 24.04)
make ci-go-ci-build-linux-static # For RHEL 8.x, SLES 15.x, Ubuntu 20.04 due to glibc dependency
Note: In case of errors encountered while cloning the OPA repository, you might try increasing the POST buffer size:
git config --global http.postBuffer 1048576000
git config --global https.postBuffer 1048576000
cd $SOURCE_ROOT/opa
make image-s390x # For RHEL 9.x, Ubuntu (22.04, 24.04)
make image-s390x-static # For RHEL 8.x, SLES 15.x, Ubuntu 20.04 due to glibc dependency
cd $SOURCE_ROOT/opa
make test
cd $SOURCE_ROOT/opa
./_release/0.69.0/opa_linux_s390x run # For RHEL 9.x, Ubuntu (22.04, 24.04)
./_release/0.69.0/opa_linux_s390x_static run # For RHEL 8.x, SLES 15.x, Ubuntu 20.04 due to glibc dependency
Please refer to Running OPA for more information
The information provided in this article is accurate at the time of writing, but on-going development in the open-source projects involved may make the information incorrect or obsolete. Please open issue or contact us on IBM Z Community if you have any questions or feedback.