将C库添加到Docker [英] Add C library to docker

查看:93
本文介绍了将C库添加到Docker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有c库依赖项的golang项目(例如pbc)。
我创建了一个dockerfile:

I have a golang project with c library dependencies(e.g pbc). I create a dockerfile:

 FROM golang:1.9.6-alpine3.7

 RUN mkdir -p /go/src/app

 WORKDIR /go/src/app

 COPY . /go/src/app

 RUN apk add --update git gcc build-base gmp flex bison

 RUN go-wrapper download

 RUN go-wrapper install

 CMD ["go-wrapper", "run", "-web"]

 EXPOSE 8000

但是我不明白如何提供pbc库,因为它是独立的库- https://crypto.stanford.edu/pbc/howto.html

However I dont understand how to provide a pbc-library, as it's standalone library - https://crypto.stanford.edu/pbc/howto.html

此库的附加动态链接。
我应该怎么做?

Additional this library linked dynamically. What should I do?

推荐答案

添加docker命令以在docker映像上下载,编译和安装库

Add the docker commands to download, compile and install the library on your docker image.

RUN wget https://crypto.stanford.edu/pbc/files/pbc-0.5.14.tar.gz && \
    tar -xvf pbc-0.5.14.tar.gz && \
    cd pbc-0.5.14 && \
    ./configure --prefix=$HOME/.local && \
    make && make install

RUN rm pbc-0.5.14.tar.gz && rm -rf pbc-0.5.14

这当然是一种非常简单的方法,您需要知道您想如何编译它,以及要使用哪些自定义标志。

this is of course a very simple way, you need to know how you want to compile it, and what custom flags to use.

这篇关于将C库添加到Docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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