I’m trying to build a custom plugin using the JavaScript PDK using Docker/docker-compose, but I’m having an issue getting started. The error I’m getting is
[crit] 1221#0: *3001 connect() to unix:/usr/local/kong/js_pluginserver.sock failed (2: No such file or directory), context: ngx.timer
I’m wondering is there any command I need to execute to initialize the plugin server?
For context, here is my Dockerfile and docker-compose.yml
Dockerfile
FROM kong:3.2.2
USER root
COPY ./kong/plugins /usr/local/kong/js-plugins
COPY --from=node:14.17.6 /usr/local/bin /usr/local/bin
COPY --from=node:14.17.6 /usr/local/lib/node_modules /usr/local/lib/node_modules
RUN npm install --unsafe -g kong-pdk@0.5.5
USER kong
docker-compose.yml
networks:
kong-net:
services:
#######################################
# Postgres: The database used by Kong
#######################################
kong-database:
image: postgres:14.1
container_name: kong-db
environment:
POSTGRES_DB: kong
POSTGRES_USER: kong
POSTGRES_PASSWORD: kong
networks:
- kong-net
healthcheck:
test: ["CMD", "pg_isready", "-U", "kong"]
interval: 10s
timeout: 5s
retries: 5
restart: on-failure
#######################################
# Kong database migration
#######################################
kong-migrations:
build: .
command: kong migrations bootstrap && kong migrations up && kong migrations finish
container_name: kong-migrations
depends_on:
kong-database:
condition: service_healthy
environment:
KONG_DATABASE: postgres
KONG_PG_HOST: kong-db
KONG_PG_USER: kong
KONG_PG_PASSWORD: kong
KONG_PG_DATABASE: kong
networks:
- kong-net
restart: on-failure
#######################################
# Kong: The API Gateway
#######################################
kong-api:
build: .
container_name: kong-api
depends_on:
kong-database:
condition: service_healthy
volumes:
- ./kong/plugins:/usr/local/kong/js-plugins
environment:
KONG_DATABASE: postgres
KONG_PG_HOST: kong-db
KONG_PG_USER: kong
KONG_PG_PASSWORD: kong
KONG_PG_DATABASE: kong
KONG_ADMIN_LISTEN: 0.0.0.0:8001
KONG_PLUGINSERVER_NAMES: js
KONG_PLUGINSERVER_JS_SOCKET: /usr/local/kong/js_pluginserver.sock
KONG_PLUGINSERVER_JS_START_CMD: /usr/local/bin/kong-js-pluginserver -v --plugins-directory /usr/local/kong/js-plugins
KONG_PLUGINSERVER_JS_QUERY_CMD: /usr/local/bin/kong-js-pluginserver --plugins-directory /usr/local/kong/js-plugins --dump-all-plugins
KONG_PLUGINS: bundled, hello
networks:
- kong-net
ports:
- "8000:8000"
- "8001:8001"
healthcheck:
test: ["CMD", "kong", "health"]
interval: 10s
timeout: 10s
retries: 1
restart: on-failure
Any suggestions for things to try would be much appreciated. Thank you!