我使用以前版本的 kong-oidc 插件更新了 Dockerfile。 Dockerfile 如下所示:
FROM kong:0.14-centos
LABEL description="Centos 7 + Kong 0.14 + kong-oidc plugin"
RUN yum install -y git unzip && yum clean all
RUN luarocks install kong-oidc 1.0.1
但运行docker build -t kong:0.14-centos-oidc 会返回此错误:
Error: Failed installing dependency: https://luarocks.org/lua-resty-openidc-1.2.3-1.src.rock - Failed installing dependency: https://luarocks.org/lua-resty-hmac-v1.0-1.rockspec - Failed installing dependency: https://luarocks.org/luacrypto-0.3.2-2.src.rock - Could not find header file for OPENSSL
No file openssl/evp.h in /usr/local/include
No file openssl/evp.h in /usr/include
You may have to install OPENSSL in your system and/or pass OPENSSL_DIR or OPENSSL_INCDIR to the luarocks command.
Example: luarocks install luacrypto OPENSSL_DIR=/usr/local
所以我们需要在 Dockerfile 中添加RUN yum install openssl-devel -y。所以,如果你再次运行docker build 命令,你会得到这个错误:
Build error: Failed compiling object src/lcrypto.oError: Failed installing dependency: https://luarocks.org/lua-resty-openidc-1.2.3-1.src.rock - Failed installing dependency: https://luarocks.org/lua-resty-hmac-v1.0-1.rockspec - Failed installing dependency: https://luarocks.org/luacrypto-0.3.2-2.src.rock - Build error: Failed compiling object src/lcrypto.o
所以我们需要安装gcc 编译器,将RUN yum install -y gcc 添加到Dockerfile。最终结果是:
FROM kong:0.14-centos
LABEL description="Centos 7 + Kong 0.14 + kong-oidc plugin"
RUN yum install -y git unzip && yum clean all
RUN yum install -y openssl-devel -y
RUN yum install -y gcc
RUN luarocks install kong-oidc 1.0.1
现在容器构建成功了,但是我认为当前的kong-oidc插件已经不再维护了。
更新:查看this repository 以获取带有 Keycloak 的 kong-oidc 插件的工作示例。