8 months 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:
KONGDATABASE: postgres KONGPGHOST: junction.proxy.rlwy.net KONGPGPORT: 45525 KONGPGUSER: postgres KONGPGPASSWORD: KJHSBdcJlvaFMOCiTXfvDGcqjpyUwPMX KONGPGDATABASE: railway # Set the correct database KONGPROXYACCESSLOG: /dev/stdout
KONGADMINACCESSLOG: /dev/stdout KONGPROXYERRORLOG: /dev/stderr
KONGADMINERRORLOG: /dev/stderr KONGADMINLISTEN: 0.0.0.0:8001 KONGADMINGUIURL: http://localhost:8002
KONGSSL: on # If you need SSL; adjust based on your settings KONGLICENSE_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 KONGDATABASE=postgres ENV KONGPGHOST=junction.proxy.rlwy.net ENV KONGPGUSER=postgres ENV KONGPGPASSWORD=KJHSBdcJlvaFMOCiTXfvDGcqjpyUwPMX ENV KONGPROXYACCESSLOG=/dev/stdout
ENV KONGADMINACCESSLOG=/dev/stdout ENV KONGPROXYERRORLOG=/dev/stderr
ENV KONGADMINERRORLOG=/dev/stderr ENV KONGADMINLISTEN=0.0.0.0:8001 ENV KONGADMINGUIURL=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 )
0 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: initbylua error: /usr/local/share/lua/5.1/kong/init.lua:689: [PostgreSQL error] failed to retrieve PostgreSQL serverversionnum: 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
initbylua(nginx-kong.conf:57):3: in main chunk
Sep 24 17:52:43
nginx: [error] initbylua error: /usr/local/share/lua/5.1/kong/init.lua:689: [PostgreSQL error] failed to retrieve PostgreSQL serverversionnum: 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
initbylua(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?
8 months 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 KONGDATABASE=postgres ENV KONGPGHOST=junction.proxy.rlwy.net ENV KONGPGPORT=45525 ENV KONGPGUSER=postgres ENV KONGPGPASSWORD=KJHSBdcJlvaFMOCiTXfvDGcqjpyUwPMX ENV KONGPGDATABASE=railway ENV KONGPGSSL=off ENV KONGPGSSLVERIFY=off
ENV KONGPROXYACCESSLOG=/dev/stdout ENV KONGADMINACCESSLOG=/dev/stdout
ENV KONGPROXYERRORLOG=/dev/stderr ENV KONGADMINERRORLOG=/dev/stderr
ENV KONGADMINLISTEN=0.0.0.0:8001
ENV KONGADMINGUI_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!