2 years ago
We are trying to deploy Kong API Gateway (with a PostgreSQL database) on Railway using the following docker-compose.yml and Dockerfile. The setup works locally in Docker Desktop, but when deployed to Railway, the deployment fails. Below are the files we are using:
docker-compose.yml -------------------------
version: "3.8"
services:
kong-gateway:
image: kong/kong-gateway:3.8.0.0
environment:
KONG_DATABASE: postgres
KONG_PG_HOST: junction.proxy.rlwy.net
KONG_PG_PORT: 45525
KONG_PG_USER: postgres
KONG_PG_PASSWORD: KJHSBdcJlvaFMOCiTXfvDGcqjpyUwPMX
KONG_PG_DATABASE: railway # Set the correct database
KONG_PROXY_ACCESS_LOG: /dev/stdout
KONG_ADMIN_ACCESS_LOG: /dev/stdout
KONG_PROXY_ERROR_LOG: /dev/stderr
KONG_ADMIN_ERROR_LOG: /dev/stderr
KONG_ADMIN_LISTEN: 0.0.0.0:8001
KONG_ADMIN_GUI_URL: http://localhost:8002
KONG_SSL: on # If you need SSL; adjust based on your settings
KONG_LICENSE_DATA: # Add your license data here if needed
ports:
- "8000:8000"
- "8443:8443"
- "8001:8001"
- "8444:8444"
- "8002:8002"
- "8445:8445"
- "8003:8003"
- "8004:8004"
networks:
kong-net:
Dockerfile -------------------------
FROM kong/kong-gateway:3.8.0.0
ENV KONG_DATABASE=postgres
ENV KONG_PG_HOST=junction.proxy.rlwy.net
ENV KONG_PG_USER=postgres
ENV KONG_PG_PASSWORD=KJHSBdcJlvaFMOCiTXfvDGcqjpyUwPMX
ENV KONG_PROXY_ACCESS_LOG=/dev/stdout
ENV KONG_ADMIN_ACCESS_LOG=/dev/stdout
ENV KONG_PROXY_ERROR_LOG=/dev/stderr
ENV KONG_ADMIN_ERROR_LOG=/dev/stderr
ENV KONG_ADMIN_LISTEN=0.0.0.0:8001
ENV KONG_ADMIN_GUI_URL=http://localhost:8002
EXPOSE 8000 8443 8001 8444 8002 8445 8003 8004
CMD ["kong", "docker-start"]
We receive the following error during deployment in deploy logs:
( Check comments for error )
4 Replies
We receive the following error during deployment in deploy logs:
Starting Container
Sep 24 17:52:38
2024/09/24 12:22:38 [warn] 1#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/kong/nginx.conf:7
Sep 24 17:52:38
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/kong/nginx.conf:7
Sep 24 17:52:43
2024/09/24 12:22:38 [error] 1#0: init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:689: [PostgreSQL error] failed to retrieve PostgreSQL server_version_num: timeout
Sep 24 17:52:43
stack traceback:
Sep 24 17:52:43
[C]: in function 'assert'
Sep 24 17:52:43
/usr/local/share/lua/5.1/kong/init.lua:689: in function 'init'
Sep 24 17:52:43
init_by_lua(nginx-kong.conf:57):3: in main chunk
Sep 24 17:52:43
nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:689: [PostgreSQL error] failed to retrieve PostgreSQL server_version_num: timeout
Sep 24 17:52:43
stack traceback:
Sep 24 17:52:43
[C]: in function 'assert'
Sep 24 17:52:43
/usr/local/share/lua/5.1/kong/init.lua:689: in function 'init'
Sep 24 17:52:43
init_by_lua(nginx-kong.conf:57):3: in main chunk
The error seems related to the PostgreSQL connection timing out. Can anyone provide guidance or help with why this might be happening in Railway?
2 years ago
FYI, docker compose is not supported by Railway https://docs.railway.app/guides/dockerfiles#docker-compose
Can we run the deployed Kong API template Gateway in local using railway CLI ??? What is the command?
We have successfully created a Dockerfile and deployed the Kong API Gateway to Railway. Here are the details:
Dockerfile
FROM kong/kong-gateway:3.8.0.0
ENV KONG_DATABASE=postgres
ENV KONG_PG_HOST=junction.proxy.rlwy.net
ENV KONG_PG_PORT=45525
ENV KONG_PG_USER=postgres
ENV KONG_PG_PASSWORD=KJHSBdcJlvaFMOCiTXfvDGcqjpyUwPMX
ENV KONG_PG_DATABASE=railway
ENV KONG_PG_SSL=off
ENV KONG_PG_SSL_VERIFY=off
ENV KONG_PROXY_ACCESS_LOG=/dev/stdout
ENV KONG_ADMIN_ACCESS_LOG=/dev/stdout
ENV KONG_PROXY_ERROR_LOG=/dev/stderr
ENV KONG_ADMIN_ERROR_LOG=/dev/stderr
ENV KONG_ADMIN_LISTEN=0.0.0.0:8001
ENV KONG_ADMIN_GUI_URL=http://localhost:8002
ENTRYPOINT ["/bin/sh", "-c", "set -e; kong migrations bootstrap; kong start && tail -f /dev/null"]
EXPOSE 8002
Kong API Gateway Deployed logs:
Starting Container
Database already bootstrapped
Kong started
However, when we attempt to access the Kong gateway GUI, we encounter an issue as shown in the attached image. Could someone help us understand what might be wrong?
Postsgres DB Deploy logs
2024-09-25 07:46:48.466 UTC [3882] LOG: could not receive data from client: Connection reset by peer
2024-09-25 07:46:48.578 UTC [3883] LOG: could not receive data from client: Connection reset by peer
2024-09-25 07:50:12.694 UTC [26] LOG: checkpoint starting: time
2024-09-25 07:50:13.186 UTC [26] LOG: checkpoint complete: wrote 4 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.327 s, sync=0.081 s, total=0.492 s; sync files=3, longest=0.072 s, average=0.027 s; distance=103 kB, estimate=148 kB; lsn=0/2EF61F8, redo lsn=0/2EF61C0
Any insights into this issue would be greatly appreciated. Thank you!
