Here are the steps to get apisonator (opensource project for 3scale backend) run locally, which can be useful for testing.
The image can be either built manually from the GitHub source, or there is an image available on quay.io.
The attached file starts redis, backend worker and backend listener.
In theory it could be possible to start APIcast with the same docker-compose
file, but there is some issue with the resolver - it doesn't pick up the services hostnames that docker-compose
resolves normally (i.e. I couldn't use http://listener:3000 from APIcast). So, I am starting APIcast locally.
- Start the apisonator components using
docker-compose
. Make sure thedocker-compose.yml
is in the current directory.
docker-compose up
- Initialize backend using the internal API using the curls in the attached file
init_backend.sh
.
chmod a+x init_backend.sh
./init_backend.sh
The script has some hardcoded values, you can modify them as you wish.
- Check that you have successfully initialized backend by runnning a curl command.
curl -XGET -v "http://127.0.0.1:3000/transactions/authorize.xml?service_token=servicetoken&service_id=1&user_key=12345"
This should give OK.
- Start APIcast locally.
git clone [email protected]:3scale/apicast.git
cd apicast
git checkout tags/v3.1.0
- start APIcast with the following command. Make sure you place the attached
config.json
inside your local copy of APIcast (or change theTHREESCALE_CONFIG_FILE
value):
THREESCALE_CONFIG_FILE=$(pwd)/config.json \
APICAST_CONFIGURATION_LOADER=boot \
THREESCALE_DEPLOYMENT_ENV=production \
BACKEND_ENDPOINT_OVERRIDE=http://127.0.0.1:3000 \
bin/apicast -vvv
You can adjust the file, but make sure you also adjust the backend init curls (namely, service ID and service token). Also note that it is adjusted to work with "API key" scheme.
- Make a test call to APIcast
curl -v "http://localhost:8080/hello" -H "user-key: 12345"
This should return a successfull response from Echo API.
You can also call Service Management API directly as follows:
curl -v "http://localhost:3000/transactions/authrep.xml?service_token=servicetoken&service_id=1&user_key=12345&usage%5Bhits%5D=1"