cmake Confluent-Kafka多阶段构建问题

brqmpdu1  于 2024-01-09  发布在  Kafka
关注(0)|答案(1)|浏览(330)

我有一个多阶段的Docker构建,如下所示,

  1. # Use an Amazon Linux 2 base image
  2. FROM amazonlinux:2.0.20230418.0 AS builder
  3. # Install build tools and dependencies
  4. RUN yum install -y gcc-c++ make openssl-devel zlib-devel librdkafka-devel && yum groupinstall -y "Development Tools"
  5. # Download librdkafka 2.2.0 source
  6. RUN cd /opt/ && git clone https://github.com/edenhill/librdkafka.git && cd librdkafka && git checkout v2.2.0 \
  7. && ./configure --prefix /usr && make -j 3 && make install && ldconfig
  8. # Build librdkafka
  9. WORKDIR /usr/src/librdkafka-2.2.0
  10. RUN ./configure --prefix=/usr \
  11. && make \
  12. && make install
  13. # Final image
  14. FROM amazonlinux:2.0.20230418.0
  15. # Copy only librdkafka binaries from builder stage
  16. COPY --from=builder /usr/lib/librdkafka* /usr/lib/
  17. COPY --from=builder /usr/include/librdkafka /usr/include/librdkafka
  18. # Set LD_LIBRARY_PATH to include librdkafka library
  19. ENV LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
  20. # Install Python and required packages
  21. RUN yum install -y python2.7 python-pip
  22. # Install confluent-kafka Python library
  23. RUN pip install confluent-kafka=2.2.0
  24. # Copy your application code
  25. COPY . /app
  26. WORKDIR /app
  27. # Command to run your application
  28. CMD ["python", "main.py"]

字符串
在我试图安装confluent-kafka后,从源代码构建librdkafka的一些原因,我总是结束了以下错误

  1. Agent pid 2036891
  2. Identity added: /home/john.doe/.ssh/id_rsa (john.doe@abc-corp)
  3. #1 [internal] load build definition from Dockerfile
  4. #1 sha256:d2adfb92a6221bec17bf4c12942bbff41d7b7280b2cf1b54bcb01e340ea55d1d
  5. #1 transferring dockerfile: 3.27kB done
  6. #1 DONE 0.0s
  7. # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  8. #REMVOED THESE LOGS AS IT WAS A SUCCESS
  9. # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  10. #
  11. #
  12. #11 84.51 Complete!
  13. #11 DONE 85.3s
  14. #12 [builder 3/5] RUN cd /opt/ && git clone https://github.com/edenhill/librdkafka.git && cd librdkafka && git checkout v2.2.0 && ./configure --prefix /usr && make -j 3 && make install && ldconfig
  15. #12 37.40 Turn off this advice by setting config variable advice.detachedHead to false
  16. #12 37.40
  17. #12 37.40 HEAD is now at e75de5be Generates a random salt only when (#4350)
  18. #12 38.27 checking for OS or distribution... ok (amzn)
  19. #12 38.27 checking for C compiler from CC env... failed
  20. #12 38.28 checking for gcc (by command)... ok
  21. #12 38.29 checking for C++ compiler from CXX env... failed
  22. #12 38.30 checking for C++ compiler (g++)... ok
  23. #12 38.32 checking executable ld... ok
  24. #12 38.33 checking executable nm... ok
  25. #12 38.34 checking executable objdump... ok
  26. #12 38.35 checking executable strip... ok
  27. #12 38.36 checking executable libtool... ok
  28. #12 38.36 checking executable ranlib... ok
  29. #12 38.37 checking for pkgconfig (by command)... ok
  30. #12 38.38 checking for install (by command)...mklove/modules/configure.base: line 1181: which: command not found
  31. #12 38.38 failed
  32. #
  33. # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  34. # REMOVED A BUNCH OF LOGS HERE
  35. # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  36. #
  37. -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c MetadataImpl.cpp -o MetadataImpl.o
  38. #12 63.97 Generating pkg-config file rdkafka++.pc
  39. #12 63.97 Generating pkg-config file rdkafka++-static.pc
  40. #12 64.36 Creating shared library librdkafka++.so.1
  41. #12 64.36 Creating static library librdkafka++.a
  42. #12 64.36 g++ -shared -Wl,-soname,librdkafka++.so.1 RdKafka.o ConfImpl.o HandleImpl.o ConsumerImpl.o ProducerImpl.o KafkaConsumerImpl.o TopicImpl.o TopicPartitionImpl.o MessageImpl.o HeadersImpl.o QueueImpl.o MetadataImpl.o -o librdkafka++.so.1 -L../src -lrdkafka
  43. #12 64.36 ar rcs librdkafka++.a RdKafka.o ConfImpl.o HandleImpl.o ConsumerImpl.o ProducerImpl.o KafkaConsumerImpl.o TopicImpl.o TopicPartitionImpl.o MessageImpl.o HeadersImpl.o QueueImpl.o MetadataImpl.o
  44. #12 64.38 cp librdkafka++.a librdkafka++-dbg.a
  45. #12 64.46 cp librdkafka++.so.1 librdkafka++-dbg.so.1
  46. #12 64.47 Creating librdkafka++.so symlink
  47. #12 64.47 rm -f "librdkafka++.so" && ln -s "librdkafka++.so.1" "librdkafka++.so"
  48. #12 64.47 Checking librdkafka++ integrity
  49. #12 64.47 librdkafka++.so.1 OK
  50. #12 64.47 librdkafka++.a OK
  51. #12 64.47 make[1]: Leaving directory `/opt/librdkafka/src-cpp'
  52. #12 64.47 make -C examples
  53. #12 64.48 make[1]: Entering directory `/opt/librdkafka/examples'
  54. #12 64.48 gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src rdkafka_example.c -o rdkafka_example \
  55. #12 64.48 ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  56. #12 64.48 gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src rdkafka_performance.c -o rdkafka_performance \
  57. #12 64.48 ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  58. #12 64.48 g++ -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -I../src-cpp rdkafka_example.cpp -o rdkafka_example_cpp \
  59. #12 64.48 ../src-cpp/librdkafka++.a ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  60. #12 64.88 # rdkafka_example is ready
  61. #12 64.89 #
  62. #12 64.89 # Run producer (write messages on stdin)
  63. #12 64.89 ./rdkafka_example -P -t <topic> -p <partition>
  64. #12 64.89
  65. #12 64.89 # or consumer
  66. #12 64.89 ./rdkafka_example -C -t <topic> -p <partition>
  67. #12 64.89
  68. #12 64.89 #
  69. #12 64.90 # More usage options:
  70. #12 64.90 ./rdkafka_example -h
  71. #12 64.90 gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src rdkafka_complex_consumer_example.c -o rdkafka_complex_consumer_example \
  72. #12 64.90 ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  73. #12 65.08 # rdkafka_performance is ready
  74. #12 65.08 #
  75. #12 65.08 # Run producer
  76. #12 65.08 ./rdkafka_performance -P -t <topic> -p <partition> -s <msgsize>
  77. #12 65.08
  78. #12 65.08 # or consumer
  79. #12 65.08 ./rdkafka_performance -C -t <topic> -p <partition>
  80. #12 65.08
  81. #12 65.09 #
  82. #12 65.09 # More usage options:
  83. #12 65.09 ./rdkafka_performance -h
  84. #12 65.09 g++ -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -I../src-cpp rdkafka_complex_consumer_example.cpp -o rdkafka_complex_consumer_example_cpp \
  85. #12 65.09 ../src-cpp/librdkafka++.a ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  86. #12 65.30 # rdkafka_complex_consumer_example is ready
  87. #12 65.31 #
  88. #12 65.31 ./rdkafka_complex_consumer_example <topic[:part]> <topic2[:part]> ..
  89. #12 65.31
  90. #12 65.31 #
  91. #12 65.31 # More usage options:
  92. #12 65.31 ./rdkafka_complex_consumer_example -h
  93. #12 65.31 g++ -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -I../src-cpp kafkatest_verifiable_client.cpp -o kafkatest_verifiable_client \
  94. #12 65.31 ../src-cpp/librdkafka++.a ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  95. #12 65.65 gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src producer.c -o producer \
  96. #12 65.65 ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  97. #12 65.95 gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src consumer.c -o consumer \
  98. #12 65.95 ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  99. #12 66.14 gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src idempotent_producer.c -o idempotent_producer \
  100. #12 66.14 ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  101. #12 66.23 gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src transactions.c -o transactions \
  102. #12 66.23 ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  103. #12 66.41 gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src delete_records.c -o delete_records \
  104. #12 66.41 ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  105. #12 66.57 g++ -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -I../src-cpp openssl_engine_example.cpp -o openssl_engine_example_cpp \
  106. #12 66.57 ../src-cpp/librdkafka++.a ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  107. #12 66.71 gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src list_consumer_groups.c -o list_consumer_groups \
  108. #12 66.71 ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  109. #12 67.15 gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src describe_consumer_groups.c -o describe_consumer_groups \
  110. #12 67.15 ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  111. #12 67.41 gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src list_consumer_group_offsets.c -o list_consumer_group_offsets \
  112. #12 67.41 ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  113. #12 67.51 gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src alter_consumer_group_offsets.c -o alter_consumer_group_offsets \
  114. #12 67.51 ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  115. #12 67.78 gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src incremental_alter_configs.c -o incremental_alter_configs \
  116. #12 67.78 ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  117. #12 67.80 gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src user_scram.c -o user_scram \
  118. #12 67.80 ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  119. #12 67.91 gcc -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -I../src misc.c -o misc \
  120. #12 67.91 ../src/librdkafka.a -lm -lssl -lcrypto -lcrypto -lz -ldl -lpthread -lrt
  121. #12 68.19 make[1]: Leaving directory `/opt/librdkafka/examples'
  122. #12 68.20 Updating CONFIGURATION.md
  123. #12 68.25 Checking integrity
  124. #12 68.25 CONFIGURATION.md OK
  125. #12 68.25 examples/rdkafka_example OK
  126. #12 68.25 examples/rdkafka_performance OK
  127. #12 68.25 examples/rdkafka_example_cpp OK
  128. #12 68.46 make[1]: Entering directory `/opt/librdkafka/src'
  129. #12 68.46 Checking librdkafka integrity
  130. #12 68.47 librdkafka.so.1 OK
  131. #12 68.47 librdkafka.a OK
  132. #12 68.47 Symbol visibility OK
  133. #12 68.47 make[1]: Leaving directory `/opt/librdkafka/src'
  134. #12 68.49 make[1]: Entering directory `/opt/librdkafka/src-cpp'
  135. #12 68.50 Generating pkg-config file rdkafka++-static.pc
  136. #12 68.50 Checking librdkafka++ integrity
  137. #12 68.50 librdkafka++.so.1 OK
  138. #12 68.50 librdkafka++.a OK
  139. #12 68.50 make[1]: Leaving directory `/opt/librdkafka/src-cpp'
  140. #12 68.54 make[1]: Entering directory `/opt/librdkafka/src'
  141. #12 68.54 Install librdkafka to /usr
  142. #12 68.54 d $DESTDIR/usr/include/librdkafka
  143. #12 68.54 /bin/sh: d: command not found
  144. #12 68.54 make[1]: [lib-install] Error 127 (ignored)
  145. #12 68.54 d $DESTDIR/usr/lib
  146. #12 68.54 /bin/sh: d: command not found
  147. #12 68.54 make[1]: [lib-install] Error 127 (ignored)
  148. #12 68.54 rdkafka.h rdkafka_mock.h $DESTDIR/usr/include/librdkafka
  149. #12 68.54 /bin/sh: rdkafka.h: command not found
  150. #12 68.54 make[1]: *** [lib-install] Error 127
  151. #12 68.54 make[1]: Leaving directory `/opt/librdkafka/src'
  152. #12 68.54 make: *** [install-subdirs] Error 2
  153. #12 ERROR: executor failed running [/bin/sh -c cd /opt/ && git clone https://github.com/edenhill/librdkafka.git && cd librdkafka && git checkout v2.2.0 && ./configure --prefix /usr && make -j 3 && make install && ldconfig]: exit code: 2
  154. ------
  155. > [builder 3/5] RUN cd /opt/ && git clone https://github.com/edenhill/librdkafka.git && cd librdkafka && git checkout v2.2.0 && ./configure --prefix /usr && make -j 3 && make install && ldconfig:
  156. ------
  157. executor failed running [/bin/sh -c cd /opt/ && git clone https://github.com/edenhill/librdkafka.git && cd librdkafka && git checkout v2.2.0 && ./configure --prefix /usr && make -j 3 && make install && ldconfig]: exit code: 2
  158. kafka_test Error on build
  159. job_done


任何帮助将不胜感激,谢谢

qq24tv8q

qq24tv8q1#

你的错误在这里

  1. #12 68.54 /bin/sh: d: command not found
  2. #12 68.54 make[1]: [lib-install] Error 127 (ignored)
  3. #12 68.54 d $DESTDIR/usr/lib
  4. #12 68.54 /bin/sh: d: command not found
  5. #12 68.54 make[1]: [lib-install] Error 127 (ignored)

字符串
这应该是cd命令,而不是d ...
你应该从YUM仓库安装,而不是从源代码克隆和构建。
否则,confluent-kafka-python会自动将其包含在二元轮中

相关问题