Docker Build Kitura Sqift容器-找不到Shim.h mysql.h文件 [英] Docker Build Kitura Sqift Container - Shim.h mysql.h file not found

查看:103
本文介绍了Docker Build Kitura Sqift容器-找不到Shim.h mysql.h文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将当前的Kitura Dev设置移至实际运行的环境,方法是先将其移至Docker容器,然后再将其迁移至Cloud Provider.

i am trying to move my current Kitura Dev setup into a real running environment by first moving it into a Docker Container to later migrate it to a Cloud Provider.

但是,在尝试为Kitura构建我的Docker安装程序时,遇到了一些问题,但我没有找到解决这些问题的适当解决方案.

However while trying to build my Docker Setup for Kitura i run into problems i did not find any proper solution how to fix these.

我正在根据本页中的说明构建Docker容器 https://www.kitura.io/docs/deploying/docker.html

I am Building my docker Container from The instructions from this page https://www.kitura.io/docs/deploying/docker.html

但是我也在软件包中使用了带有MySQL的SwiftKuery.

But i am also using SwiftKuery with MySQL in the package.

我的Docker Tools文件如下所示

My Docker Tools file looks like the following

FROM ibmcom/swift-ubuntu:5.0.2
##FROM swift:5.0.2

LABEL maintainer="IBM Swift Engineering at IBM Cloud"
LABEL Description="Template Dockerfile that extends the ibmcom/swift-ubuntu image."

# We can replace this port with what the user wants
EXPOSE 8080 1024 1025

# Default user if not provided
ARG bx_dev_user=root
ARG bx_dev_userid=1000

# Install system level packages
RUN apt-get update && apt-get dist-upgrade -y
##RUN apt-get update && apt-get install -y sudo libcurl4-openssl-dev openssl libssl-dev pkg-config libmysqlclient-dev

# Add utils files
ADD https://raw.githubusercontent.com/IBM-Swift/swift-ubuntu-docker/master/utils/tools-utils.sh /swift-utils/tools-utils.sh
ADD https://raw.githubusercontent.com/IBM-Swift/swift-ubuntu-docker/master/utils/common-utils.sh /swift-utils/common-utils.sh
RUN chmod -R 555 /swift-utils

# Create user if not root
RUN if [ "$bx_dev_user" != root ]; then useradd -ms /bin/bash -u $bx_dev_userid $bx_dev_user; fi

# Make password not required for sudo.
# This is necessary to run 'tools-utils.sh debug' script when executed from an interactive shell.
# This will not affect the deploy container.
RUN echo "$bx_dev_user ALL=NOPASSWD: ALL" > /etc/sudoers.d/user && \
    chmod 0440 /etc/sudoers.d/user

#Install some further SSL related flaws
##RUN  find / -name libssl.so.1.1 -type f -print

# Bundle application source & binaries
COPY . /swift-project

我收到以下错误

[5/24] Compiling Swift Module 'SwiftKueryMySQL' (3 sources)
[6/24] Compiling Swift Module 'KituraContracts' (9 sources)
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "shim.h"
         ^
/swift-project/.build-ubuntu/checkouts/SwiftKueryMySQL/Sources/CMySQL/shim.h:3:10: error: 'mysql.h' file not found
#include <mysql.h>
         ^
/swift-project/.build-ubuntu/checkouts/SwiftKueryMySQL/Sources/SwiftKueryMySQL/MySQLConnection.swift:21:8: error: could not build C module 'CMySQL'
import CMySQL
       ^

使用此命令后

docker build -t myapp-build -f Dockerfile-tools .

第一个仍然有效

docker run -v $PWD:/swift-project -w /swift-project myapp-build /swift-utils/tools-utils.sh build release

构建容器时出现错误

任何人都有一个想法,我可以做些什么来解决此问题...?

Any one has an idea what i could do to fix this issue ... ?

更新:

我尝试了一个提供的建议来添加.swift-build-linux文件 一个条目

I tried one provided suggestion to add a .swift-build-linux file with one entry

swift build -Xcc -I/usr/include/mysql/

进入我项目的源文件.

运行命令:

docker run -v $PWD:/swift-project -w /swift-project myapp-build /swift-utils/tools-utils.sh build release

您似乎可以在下面看到它...但是我仍然遇到相同的问题:(

It seems to pick it up as you can see below... but still i run into the same issue :(

Current folder: /swift-project
Command: build
Build configuration: release
Build folder: /swift-project/.build-ubuntu
Compiling the project...
Build configuration: release
Custom build command: swift build -Xcc -I/usr/include/mysql/££
warning: you may be able to install mysqlclient using your system-packager:
     apt-get install libmysqlclient-dev

[1/27] Compiling agentcore ibmras/common/Logger.cpp
[2/27] Compiling agentcore ibmras/common/MemoryManager.cpp
[3/27] Compiling agentcore ibmras/common/Properties.cpp
[4/27] Compiling agentcore ibmras/common/LogManager.cpp
[5/26] Compiling Swift Module 'SwiftKueryMySQL' (3 sources)
[6/26] Compiling Swift Module 'KituraContracts' (9 sources)
[7/26] Compiling Swift Module 'CloudFoundryEnv' (6 sources)
[8/26] Compiling CHTTPParser utils.c
[9/26] Linking ./.build-ubuntu/x86_64-unknown-linux/release/libagentcore.so
[10/26] Compiling CHTTPParser http_parser.c
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "shim.h"
         ^
/swift-project/.build-ubuntu/checkouts/SwiftKueryMySQL/Sources/CMySQL/shim.h:3:10: error: 'mysql.h' file not found
#include <mysql.h>
         ^
/swift-project/.build-ubuntu/checkouts/SwiftKueryMySQL/Sources/SwiftKueryMySQL/MySQLConnection.swift:21:8: error: could not build C module 'CMySQL'
import CMySQL
       ^
Kais-MacBook-Pro:beautylivery_server_mqsql kaibaier$ docker run -v $PWD:/swift-project -w /swift-project myapp-build /swift-utils/tools-utils.sh build release
Current folder: /swift-project
Command: build
Build configuration: release
Build folder: /swift-project/.build-ubuntu
Compiling the project...
Build configuration: release
Custom build command: swift build -Xcc -I/usr/include/mysql/
warning: you may be able to install mysqlclient using your system-packager:
     apt-get install libmysqlclient-dev

[1/33] Compiling CHTTPParser http_parser.c
[2/39] Compiling CHTTPParser utils.c
[3/65] Compiling Swift Module 'TypeDecoder' (2 sources)
[4/65] Compiling Swift Module 'Socket' (3 sources)
[5/65] Compiling Swift Module 'Signals' (1 sources)
[6/65] Compiling Swift Module 'Logging' (3 sources)
[7/65] Compiling Swift Module 'KituraTemplateEngine' (1 sources)
[8/65] Compiling Swift Module 'Cryptor' (11 sources)
[9/65] Compiling memplugin MemoryPlugin.cpp
[10/65] Compiling Swift Module 'LoggerAPI' (1 sources)
[11/65] Compiling hcapiplugin APIConnector.cpp
[12/65] Linking ./.build-ubuntu/x86_64-unknown-linux/release/libmemplugin.so
[13/65] Compiling envplugin envplugin.cpp
[14/65] Linking ./.build-ubuntu/x86_64-unknown-linux/release/libhcapiplugin.so
[15/65] Compiling cpuplugin cpuplugin.cpp
[16/65] Compiling Swift Module 'SwiftKuery' (49 sources)
[17/65] Compiling Swift Module 'KituraContracts' (9 sources)
[18/65] Compiling Swift Module 'HeliumLogger' (2 sources)
[19/65] Compiling Swift Module 'SSLService' (2 sources)
[20/65] Compiling Swift Module 'Health' (3 sources)
[21/65] Compiling Swift Module 'FileKit' (1 sources)
[22/65] Compiling Swift Module 'Configuration' (5 sources)
[23/65] Compiling agentcore ibmras/monitoring/connector/configuration/ConfigurationConnector.cpp
[24/65] Linking ./.build-ubuntu/x86_64-unknown-linux/release/libenvplugin.so
[25/65] Linking ./.build-ubuntu/x86_64-unknown-linux/release/libcpuplugin.so
[26/65] Compiling agentcore ibmras/monitoring/connector/ConnectorManager.cpp
[27/65] Compiling agentcore ibmras/monitoring/agent/threads/WorkerThread.cpp
[28/65] Compiling agentcore ibmras/monitoring/agent/threads/ThreadPool.cpp
[29/65] Compiling agentcore ibmras/monitoring/agent/SystemReceiver.cpp
[30/65] Compiling agentcore ibmras/monitoring/agent/BucketList.cpp
[31/65] Compiling agentcore ibmras/monitoring/agent/Bucket.cpp
[32/65] Compiling Swift Module 'CloudFoundryEnv' (6 sources)
[33/65] Compiling agentcore ibmras/monitoring/agent/Agent.cpp
[34/65] Compiling agentcore ibmras/monitoring/Plugin.cpp
[35/65] Compiling agentcore ibmras/common/util/sysUtils.cpp
[36/65] Compiling agentcore ibmras/common/util/strUtils.cpp
[37/65] Compiling agentcore ibmras/common/util/LibraryUtils.cpp
[38/65] Compiling agentcore ibmras/common/util/FileUtils.cpp
[39/65] Compiling agentcore ibmras/common/port/linux/Thread.cpp
[40/65] Compiling Swift Module 'SwiftKueryMySQL' (3 sources)
[41/65] Compiling agentcore ibmras/common/port/linux/Process.cpp
[42/65] Compiling agentcore ibmras/common/port/ThreadData.cpp
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "shim.h"
         ^
/swift-project/.build-ubuntu/checkouts/SwiftKueryMySQL/Sources/CMySQL/shim.h:3:10: error: 'mysql.h' file not found
#include <mysql.h>
         ^
/swift-project/.build-ubuntu/checkouts/SwiftKueryMySQL/Sources/SwiftKueryMySQL/MySQLConnection.swift:21:8: error: could not build C module 'CMySQL'
import CMySQL
       ^

更新:

在我在Dockerfile-tools中添加此行后,它似乎可以工作. :

It seems to work after i added this line in my Dockerfile-tools . :

RUN apt-get update && apt-get install -y sudo libmysqlclient-dev 

...但是现在我遇到了一个新错误,我首先必须调查...

... but now i get a new error i first have to investigate ...

[19/20] Compiling Swift Module 'Beautylivery_Server_New' (1 sources) [20/20] Linking ./.build-ubuntu/x86_64-unknown-linux/release/Beautylivery_Server_New clang-7: error: unable to execute command: Bus error clang-7: error: linker command failed due to signal (use -v to see invocation) <unknown>:0: error: link command failed with exit code 254 (use -v to see invocation)

更新-分辨率:

好吧,我添加了条目

swift build -Xcc -I/usr/include/mysql/

到我项目的根目录中新创建的.swift-build-linux文件. (以前我在该行中有一个小的拼写错误).

to the new created .swift-build-linux file in the root directory in my project. (previously i had a small spelling mistake in the line).

现在,我能够通过Dockerisation流程的这一步... :)

Now i was able to pass this step of the Dockerisation process ... :)

更新-新问题:

你好,我遇到了一个与本教程相关的新问题,这是在构建容器之后运行容器:由于我认为这是一个不同的主题,所以我提出了一个新问题: 运行Kitura Docker Image会导致libmysqlclient.so.18错误

Hello Together, i was running in a new problem related to the tutorial and this is to run the conatainer after building it: As i assume it is a different topic, i have raised a new question: Run Kitura Docker Image causes libmysqlclient.so.18 Error

是在运行容器时,我收到一条错误消息:

its is that up on running the container, i get an error message:

error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory

非常感谢您的帮助!

推荐答案

此处的问题是ibmcom/swift-ubuntu:5.0.2映像是在Ubuntu 14.04之上构建的. 14.04随附的libmysqlclient-dev版本不包含pkg-config信息,该信息使Swift编译器无需帮助即可查找标头.

The problem here is that the ibmcom/swift-ubuntu:5.0.2 image is built on top of Ubuntu 14.04. The version of libmysqlclient-dev supplied with 14.04 does not include the pkg-config information that allows the Swift compiler to find the headers without help.

对此问题有两种解决方法:

There are two solutions to this problem:

1:您可以将-Xcc -I/usr/include/mysql/参数添加到swift build命令.要么

1: You could add -Xcc -I/usr/include/mysql/ arguments to the swift build command. Either:

  • swift build -Xcc -I/usr/include/mysql/
  • 替换您正在构建容器中执行的命令
  • 如果您想继续使用tools-utils.sh脚本,则可以在项目中创建一个名为.swift-build-linux的文件,该文件包含一行:swift build -Xcc -I/usr/include/mysql/-这将由tools-utils.sh脚本提取当它运行构建时.
  • replace the command you are executing in the build container with swift build -Xcc -I/usr/include/mysql/, or
  • if you'd like to keep using the tools-utils.sh script, you can create a file in your project called .swift-build-linux which contains a single line: swift build -Xcc -I/usr/include/mysql/ - this will be picked up by the tools-utils.sh script when it runs the build.

2:您可以用FROM swift:5.0.2(用于构建映像)和FROM swift:5.0.2-slim(用于运行映像)替换您的基础映像-这些是基于Ubuntu 18.04的Swift官方维护的映像,并且自Swift 5.0.2版本提供了类似于ibmcom的运行时"映像的苗条"映像.

2: You can replace your base images with FROM swift:5.0.2 (for the build image) and FROM swift:5.0.2-slim (for the run image) - these are the official Swift-maintained images which are based on Ubuntu 18.04, and as of the Swift 5.0.2 release, provide a 'slim' image similar to ibmcom's 'runtime' image.

  • 请注意,这些映像不会捆绑libssl-devlibcurl4-openssl-dev依赖项,因此您需要将这些映像包括在Dockerfile-tools中.
  • Note that these images do not bundle the libssl-dev or libcurl4-openssl-dev dependencies, so you will need to include those in your Dockerfile-tools.

这篇关于Docker Build Kitura Sqift容器-找不到Shim.h mysql.h文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆