api7 / apisix-build-tools

Build tools to package and release
Apache License 2.0
124 stars 95 forks source link

An error while compiling with tongsuo. #282

Open scoolor opened 1 year ago

scoolor commented 1 year ago

I encountered an error when compiling with tongsuo, while compiling separately with ./build-apisix-base.sh doesn't produce any error. It seems like there is a bug when specifying the compilation environment variables.

This is the Dockerfile:

FROM debian:latest

RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    git \
    libreadline-dev \
    libncurses5-dev \
    libpcre3-dev \
    libssl-dev \
    perl \
    perl-modules \
    unzip \
    sudo \
    zlib1g-dev \
    wget

COPY ./tongsuo /tongsuo
WORKDIR /tongsuo
RUN ./config shared enable-ntls -g --prefix=/usr/local/tongsuo \
    && make -j2 \ 
    && make install_sw

ENV OR_PREFIX=/usr/local/openresty
ENV openssl_prefix=/usr/local/tongsuo
ENV zlib_prefix=$OR_PREFIX/zlib
ENV pcre_prefix=$OR_PREFIX/pcre
ENV cc_opt="-DNGX_LUA_ABORT_AT_PANIC -I${zlib_prefix}/include -I${pcre_prefix}/include -I${openssl_prefix}/include"
ENV ld_opt="-L${zlib_prefix}/lib -L${pcre_prefix}/lib -L${openssl_prefix}/lib64 -Wl,-rpath,${zlib_prefix}/lib:${pcre_prefix}/lib:${openssl_prefix}/lib64"

COPY ./apisix-build-tools /apisix-build-tools
WORKDIR /apisix-build-tools
RUN ./build-apisix-base.sh

Some output:

#13 42.16 objs/addon/http/ngx_http_wasm_call.o \
#13 42.16 objs/addon/http/ngx_http_wasm_state.o \
#13 42.16 objs/addon/proxy_wasm/proxy_wasm_map.o \
#13 42.16 objs/addon/proxy_wasm/proxy_wasm_memory.o \
#13 42.16 objs/addon/vm/wasmtime.o \
#13 42.16 objs/addon/vm/vm.o \
#13 42.16 objs/addon/src/ngx_http_lua_var_module.o \
#13 42.16 objs/addon/src/ngx_grpc_client.o \
#13 42.16 objs/ngx_modules.o \
#13 42.16 -L/tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/luajit-root/usr/local/openresty/luajit/lib -L/tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/luajit-root/usr/local/openresty/luajit/lib -Wl,-rpath,/usr/local/openresty/luajit/lib -Wl,-rpath,/usr/local/openresty/wasmtime-c-api/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/tongsuo/lib64 -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/tongsuo/lib64 -Wl,--require-defined=pcre_version -Wl,-E -Wl,-E -ldl -lpthread -lpthread -lcrypt -L/tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/luajit-root/usr/local/openresty/luajit/lib -lluajit-5.1 -lm -ldl -L/tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/luajit-root/usr/local/openresty/luajit/lib -lluajit-5.1 -lm -ldl -lstdc++ -L/tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/../wasm-nginx-module-0.6.4/wasmtime-c-api/lib -lwasmtime -lpcre -lssl -lcrypto -ldl -lpthread -lz \
#13 42.16 -Wl,-E
#13 42.32 /usr/bin/ld: objs/src/event/ngx_event_openssl.o: in function `ngx_ssl_error':
#13 42.32 /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4/src/event/ngx_event_openssl.c:3527: undefined reference to `ERR_peek_error_data'
#13 42.32 /usr/bin/ld: /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4/src/event/ngx_event_openssl.c:3527: undefined reference to `ERR_peek_error_data'
#13 42.32 /usr/bin/ld: objs/src/event/ngx_event_openssl.o: in function `ngx_ssl_session_ticket_key_callback':
#13 42.32 /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4/src/event/ngx_event_openssl.c:4423: undefined reference to `EVP_CIPHER_get_iv_length'
#13 42.32 /usr/bin/ld: objs/src/event/ngx_event_openssl.o: in function `ngx_ssl_sendfile':
#13 42.32 /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4/src/event/ngx_event_openssl.c:3031: undefined reference to `SSL_sendfile'
#13 42.32 /usr/bin/ld: objs/src/event/ngx_event_openssl.o: in function `ngx_ssl_check_host':
#13 42.32 /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4/src/event/ngx_event_openssl.c:4546: undefined reference to `SSL_get1_peer_certificate'
#13 42.32 /usr/bin/ld: objs/src/event/ngx_event_openssl.o: in function `ngx_ssl_get_raw_certificate':
#13 42.32 /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4/src/event/ngx_event_openssl.c:5016: undefined reference to `SSL_get1_peer_certificate'
#13 42.32 /usr/bin/ld: objs/src/event/ngx_event_openssl.o: in function `ngx_ssl_get_subject_dn':
#13 42.32 /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4/src/event/ngx_event_openssl.c:5140: undefined reference to `SSL_get1_peer_certificate'
#13 42.32 /usr/bin/ld: objs/src/event/ngx_event_openssl.o: in function `ngx_ssl_get_issuer_dn':
#13 42.32 /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4/src/event/ngx_event_openssl.c:5194: undefined reference to `SSL_get1_peer_certificate'
#13 42.32 /usr/bin/ld: objs/src/event/ngx_event_openssl.o: in function `ngx_ssl_get_subject_dn_legacy':
#13 42.32 /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4/src/event/ngx_event_openssl.c:5250: undefined reference to `SSL_get1_peer_certificate'
#13 42.32 /usr/bin/ld: objs/src/event/ngx_event_openssl.o:/tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4/src/event/ngx_event_openssl.c:5298: more undefined references to `SSL_get1_peer_certificate' follow
#13 42.32 /usr/bin/ld: objs/src/http/ngx_http_request.o: in function `ngx_http_ssl_handshake':
#13 42.32 /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4/src/http/ngx_http_request.c:762: undefined reference to `SSL_enable_ntls'
#13 42.34 /usr/bin/ld: objs/src/stream/ngx_stream_ssl_module.o: in function `ngx_stream_ssl_handler':
#13 42.34 /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4/src/stream/ngx_stream_ssl_module.c:372: undefined reference to `SSL_get1_peer_certificate'
#13 42.35 /usr/bin/ld: objs/addon/src/ngx_http_encrypted_session_cipher.o: in function `ngx_http_encrypted_session_aes_mac_encrypt':
#13 42.35 /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4/../encrypted-session-nginx-module-0.09/src/ngx_http_encrypted_session_cipher.c:54: undefined reference to `EVP_CIPHER_get_block_size'
#13 42.35 /usr/bin/ld: objs/addon/src/ngx_http_encrypted_session_cipher.o: in function `ngx_http_encrypted_session_aes_mac_decrypt':
#13 42.35 /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4/../encrypted-session-nginx-module-0.09/src/ngx_http_encrypted_session_cipher.c:180: undefined reference to `EVP_CIPHER_get_block_size'
#13 42.37 /usr/bin/ld: objs/addon/src/ngx_http_lua_ssl_session_fetchby.o: in function `ngx_http_lua_ssl_sess_fetch_handler':
#13 42.37 /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4/../ngx_lua-0.10.21/src/ngx_http_lua_ssl_session_fetchby.c:354: undefined reference to `SSL_magic_pending_session_ptr'
#13 42.38 /usr/bin/ld: objs/addon/src/ngx_http_apisix_module.o: in function `ngx_http_apisix_set_gm_cert':
#13 42.38 /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/../apisix-nginx-module-1.12.0/src/ngx_http_apisix_module.c:717: undefined reference to `SSL_use_sign_certificate'
#13 42.38 /usr/bin/ld: /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/../apisix-nginx-module-1.12.0/src/ngx_http_apisix_module.c:712: undefined reference to `SSL_use_enc_certificate'
#13 42.38 /usr/bin/ld: objs/addon/src/ngx_http_apisix_module.o: in function `ngx_http_apisix_set_gm_priv_key':
#13 42.38 /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/../apisix-nginx-module-1.12.0/src/ngx_http_apisix_module.c:791: undefined reference to `SSL_use_sign_PrivateKey'
#13 42.38 /usr/bin/ld: /tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/../apisix-nginx-module-1.12.0/src/ngx_http_apisix_module.c:786: undefined reference to `SSL_use_enc_PrivateKey'
#13 42.41 collect2: error: ld returned 1 exit status
#13 42.41 make[2]: *** [objs/Makefile:541: objs/nginx] Error 1
#13 42.41 make[2]: Leaving directory '/tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4'
#13 42.41 make[1]: Leaving directory '/tmp/tmp.zFDQleS1ZK/openresty-1.21.4.1/build/nginx-1.21.4'
#13 42.41 make[1]: *** [Makefile:10: build] Error 2
#13 42.41 make: *** [Makefile:8: all] Error 2
------
executor failed running [/bin/sh -c export OR_PREFIX=/usr/local/openresty     && export openssl_prefix=/usr/local/tongsuo     && export zlib_prefix=$OR_PREFIX/zlib     && export pcre_prefix=$OR_PREFIX/pcre     && export cc_opt="-DNGX_LUA_ABORT_AT_PANIC -I${zlib_prefix}/include -I${pcre_prefix}/include -I${openssl_prefix}/include"     && export ld_opt="-L${zlib_prefix}/lib -L${pcre_prefix}/lib -L${openssl_prefix}/lib64 -Wl,-rpath,${zlib_prefix}/lib:${pcre_prefix}/lib:${openssl_prefix}/lib64"     && ./build-apisix-base.sh]: exit code: 2
zqge commented 1 year ago

Has this problem been resolved? If so, can you provide the correct dockerfile

bugfan commented 1 year ago

Hi you can use this Dockerfile build apisix-gm image

`FROM debian:bullseye-slim as base

RUN set -ex; \ apt update; \ apt-get -y install --no-install-recommends wget gnupg ca-certificates git curl gcc g++ make libssl-dev xz-utils sudo libldap2-dev libpcre3-dev unzip patch zlib1g-dev;

WORKDIR / RUN git clone https://github.com/api7/tongsuo --depth 1 WORKDIR /tongsuo

RUN ./config shared enable-ntls -g --prefix=/usr/local/tongsuo \ && make -j2 \ && sudo make install_sw

ARG OR_PREFIX=/usr/local/openresty ARG openssl_prefix=/usr/local/tongsuo ARG zlib_prefix=$OR_PREFIX/zlib ARG pcre_prefix=$OR_PREFIX/pcre ARG cc_opt="-DNGX_LUA_ABORT_AT_PANIC -I${zlib_prefix}/include -I${pcre_prefix}/include -I${openssl_prefix}/include" ARG ld_opt="-L${zlib_prefix}/lib -L${pcre_prefix}/lib -L${openssl_prefix}/lib64 -Wl,-rpath,${zlib_prefix}/lib:${pcre_prefix}/lib:${openssl_prefix}/lib64"

RUN git clone https://github.com/api7/apisix-build-tools.git /apisix-build-tools WORKDIR /apisix-build-tools

RUN ./build-apisix-base.sh

ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin

RUN curl https://raw.githubusercontent.com/apache/apisix/master/utils/install-dependencies.sh -sL | bash -

RUN cp -rf /usr/local/tongsuo /usr/local/openresty \ && mv /usr/local/openresty/tongsuo /usr/local/openresty/openssl \ && mv /usr/local/openresty/openssl/lib64 /usr/local/openresty/openssl/lib

COPY ./install-deps.sh /install-deps.sh COPY ./install-luarocks.sh /install-luarocks.sh

WORKDIR /

RUN bash /install-luarocks.sh

COPY ./apisix /apisix

WORKDIR /apisix

RUN make deps \ && make install

WORKDIR /usr/local/apisix

RUN rm -rf /apisix-build-tools /install-deps.sh /install-luarocks.sh /tongsuo

COPY ./apisix-inner /usr/local/apisix

FROM debian:bullseye-slim

COPY --from=base /usr/local /usr/local COPY --from=base /usr/bin/apisix /usr/bin/apisix

RUN rm -rf /usr/local/go

ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin

forward request and error logs to docker log collector

RUN ln -sf /dev/stdout /usr/local/apisix/logs/access.log \ && ln -sf /dev/stderr /usr/local/apisix/logs/error.log

EXPOSE 9080 9443

COPY ./docker-entrypoint.sh /docker-entrypoint.sh

RUN chmod +x /docker-entrypoint.sh

ENTRYPOINT ["/docker-entrypoint.sh"]

CMD ["docker-start"]

STOPSIGNAL SIGQUIT`