Replies: 1 comment
-
Hey @bestjane! 👋 I'm here to help you with your APISIX and Docker questions. I'm a bot designed to assist with bug fixes, answer questions, and guide you through becoming a contributor. Let's tackle this challenge together! To add PostgreSQL support to your new plug-in using Docker deployment mode without rebuilding the APISIX image, follow these steps:
Here is an example Docker Compose file and the necessary configurations: Docker Compose Fileversion: "3"
services:
postgres:
image: postgres:15-alpine
environment:
POSTGRES_PASSWORD: "root"
volumes:
- ./postgres:/docker-entrypoint-initdb.d:ro
postgrest:
build: ./postgrest
volumes:
- ./postgrest/product.conf:/etc/product.conf:ro
ports:
- "3000:3000"
entrypoint: ["/postgrest/postgrest"]
command: ["/etc/product.conf"]
depends_on:
- postgres
apisix:
image: apache/apisix:2.15.0-alpine
volumes:
- ./apisix/config.yml:/usr/local/apisix/conf/config.yaml:ro
ports:
- "9080:9080"
restart: always
depends_on:
- etcd
- postgrest
etcd:
image: bitnami/etcd:3.5.2
environment:
ETCD_ENABLE_V2: "true"
ALLOW_NONE_AUTHENTICATION: "yes"
ETCD_ADVERTISE_CLIENT_URLS: "http://0.0.0.0:2397"
ETCD_LISTEN_CLIENT_URLS: "http://0.0.0.0:2397" PostgREST DockerfileFROM debian:bookworm-slim
ARG POSTGREST_VERSION=v10.1.1
ARG POSTGREST_FILE=postgrest-$POSTGREST_VERSION-linux-static-x64.tar.xz
RUN mkdir postgrest
WORKDIR postgrest
ADD https://github.com/PostgREST/postgrest/releases/download/$POSTGREST_VERSION/$POSTGREST_FILE .
RUN apt-get update && \
apt-get install -y libpq-dev xz-utils && \
tar xvf $POSTGREST_FILE && \
rm $POSTGREST_FILE APISIX ConfigurationConfigure APISIX to proxy calls to PostgREST: curl http://apisix:9080/apisix/admin/upstreams/1 -H 'X-API-KEY: 123xyz' -X PUT -d '
{
"type": "roundrobin",
"nodes": {
"postgrest:3000": 1
}
}'
curl http://apisix:9080/apisix/admin/routes/1 -H 'X-API-KEY: 123xyz' -X PUT -d '
{
"uri": "/*",
"upstream_id": 1
}' Query the EndpointYou can now query the endpoint via APISIX: curl localhost:9080/product This setup allows you to add PostgreSQL support to your new plug-in using Docker deployment mode without rebuilding the APISIX image [1]. |
Beta Was this translation helpful? Give feedback.
-
Whether the image of APISIX must be rebuilt? What do I have to do if I don't want to rebuild
Beta Was this translation helpful? Give feedback.
All reactions