首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Docker容器中node-oracledb的问题

Docker容器中node-oracledb的问题
EN

Stack Overflow用户
提问于 2020-06-16 12:14:24
回答 1查看 653关注 0票数 1

我有一个通过TypeORM连接到Oracle数据库的Nest.js应用程序,我正在尝试使用Docker将我的应用程序容器化。所以这里的问题是,当应用程序没有被容器化时,它工作得很好,但当我这样做时,我得到了以下错误。

代码语言:javascript
运行
复制
[Nest] 19   - 06/16/2020, 4:00:52 AM   [TypeOrmModule] Unable to connect to the database. Retrying (4)... +3003ms
 Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help
Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
You must have 64-bit Oracle client libraries in LD_LIBRARY_PATH, or configured with ldconfig.
If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
    at OracleDb.createPool (/app/node_modules/oracledb/lib/oracledb.js:202:8)
    at OracleDb.createPool (/app/node_modules/oracledb/lib/util.js:185:19)

我确保在Dockerfile中添加Oracle瘦客户机所需的依赖项,如下所示

代码语言:javascript
运行
复制
FROM oraclelinux:7-slim
RUN  yum -y install oracle-release-el7 oracle-nodejs-release-el7 && \
   yum-config-manager --disable ol7_developer_EPEL --enable ol7_oracle_instantclient && \
   yum -y install oracle-instantclient19.5-basiclite && \
   rm -rf /var/cache/yum

FROM node:10
WORKDIR /app
COPY ./package.json ./

我不确定要在这里添加什么才能使其正常工作。我从这里的https://oracle.github.io/node-oracledb/INSTALL.html#docker获得了一些关于如何为oracle客户端添加内容的说明

EN

回答 1

Stack Overflow用户

发布于 2020-06-27 12:26:35

看起来您正在尝试使用多阶段构建。我在我的博客posst Docker for Oracle Database Applications in Node.js and Python的"Node.js Dockerfile示例3“中讨论了这一点。

您可以尝试如下所示:

代码语言:javascript
运行
复制
FROM oraclelinux:7-slim as builder

ARG release=19
ARG update=5

RUN yum -y install oracle-release-el7 &&
     oracle-instantclient${release}.${update}-basiclite

RUN rm -rf /usr/lib/oracle/${release}.${update}/client64/bin
WORKDIR /usr/lib/oracle/${release}.${update}/client64/lib/
RUN rm -rf *jdbc* *occi* *mysql* *jar

# Get a new image
FROM node:12-buster-slim

# Copy the Instant Client libraries, licenses and config file from the previous image
COPY --from=builder /usr/lib/oracle /usr/lib/oracle
COPY --from=builder /usr/share/oracle /usr/share/oracle
COPY --from=builder /etc/ld.so.conf.d/oracle-instantclient.conf /etc/ld.so.conf.d/oracle-instantclient.conf

RUN apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade && apt-get install -y libaio1 && \
    apt-get -y autoremove && apt-get -y clean && \
    ldconfig

总体而言,这可能不值得这么复杂。看看博客文章中的另一个例子。或者使用Oracle的Dockerfile文件:https://github.com/oracle/docker-images/tree/master/OracleLinuxDevelopers/oraclelinux7/nodejs/12-oracledb

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62400821

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档