diff --git a/CloudronPackages/APISIX/APISIX-BuildNotes.md b/CloudronPackages/APISIX/APISIX-BuildNotes.md index c5063ad..f4daab0 100644 --- a/CloudronPackages/APISIX/APISIX-BuildNotes.md +++ b/CloudronPackages/APISIX/APISIX-BuildNotes.md @@ -24,14 +24,11 @@ APISIX is configured to use Cloudron's managed etcd addon. The `start.sh` script ### Health Check Cloudron's health check for the APISIX application is currently configured to probe the `/health` path. While APISIX primarily uses its Control API (`/v1/healthcheck`) for monitoring *upstream services*, `/health` is a common convention for application liveness probes. If issues arise with Cloudron's health monitoring, further investigation into a more specific APISIX health endpoint or a custom health check script may be required. -## Post-Installation Steps - -1. **Accessing the Admin API**: As mentioned above, use the `CLOUDRON_APP_SECRET` as the `X-API-KEY` header to interact with the APISIX Admin API. -2. **Initial Configuration**: After installation, you may need to use the Admin API to configure routes, upstreams, and plugins for your specific use case. - ## Local Testing -To test the package locally: +**Note**: Local testing of APISIX in standalone mode (without a live etcd instance) has proven challenging due to APISIX's internal dependencies on etcd, even when configured for filesystem data storage. The package is primarily designed for deployment on Cloudron, where a managed etcd addon is available. + +To test the package locally (requires a running etcd instance accessible at `localhost:2379`): 1. **Build the Docker image**: ```bash @@ -50,12 +47,11 @@ To test the package locally: ```bash curl -i http://localhost:9080/status ``` - This should return APISIX status information. - 4. **Test Admin API (replace with your test key)**: ```bash curl -i -X GET "http://localhost:9080/apisix/admin/routes" -H "X-API-KEY: your_test_admin_key" ``` ## Known Issues / Limitations -- The `/health` endpoint for Cloudron's health check might not be ideal for APISIX's internal state. Monitor closely. +- Local standalone testing without a dedicated etcd instance is difficult due to APISIX's inherent design. +- The `/health` endpoint for Cloudron's health check might not be ideal for APISIX's internal state. Monitor closely. \ No newline at end of file diff --git a/CloudronPackages/APISIX/start.sh b/CloudronPackages/APISIX/start.sh index 0786290..4287933 100644 --- a/CloudronPackages/APISIX/start.sh +++ b/CloudronPackages/APISIX/start.sh @@ -1,12 +1,18 @@ #!/usr/bin/env bash -set -euo pipefail +set -euxo pipefail -# Set APISIX prefix -PREFIX=${APISIX_PREFIX:=/usr/local/apisix} +# Set APISIX prefix to /app/code +PREFIX=/app/code + +# Log file for APISIX output +LOG_FILE="/app/data/apisix.log" + +# Ensure /app/data/conf exists +mkdir -p /app/data/conf # Generate APISIX configuration (config.yaml) to connect to Cloudron etcd -cat < ${PREFIX}/conf/config.yaml +cat < /app/data/conf/config.yaml apisix: etcd: host: @@ -24,11 +30,17 @@ deployment: EOF +# Set APISIX_CONF_FILE environment variable +export APISIX_CONF_FILE=/app/data/conf/config.yaml + # Initialize APISIX -/usr/bin/apisix init +/app/code/bin/apisix init >> "${LOG_FILE}" 2>&1 # Initialize etcd connection for APISIX -/usr/bin/apisix init_etcd +/app/code/bin/apisix init_etcd >> "${LOG_FILE}" 2>&1 # Start OpenResty (APISIX server) -exec /usr/local/openresty/bin/openresty -p ${PREFIX} -g 'daemon off;' +/usr/local/openresty/bin/openresty -p ${PREFIX} -g 'daemon off;' >> "${LOG_FILE}" 2>&1 & + +# Tail the log file to keep the container running and show output +tail -f "${LOG_FILE}" \ No newline at end of file