pgroonga / docker

Dockerfile for PGroonga
https://hub.docker.com/r/groonga/pgroonga
MIT License
35 stars 9 forks source link

Fail to build docker image #41

Closed komainu8 closed 4 months ago

komainu8 commented 4 months ago

Fail to build docker image for Alpine Linux as below. https://github.com/pgroonga/docker/actions/runs/9554591639/job/26335980522#step:7:4970

#12 [linux/amd64 4/5] RUN   /build.sh 3.2.0 14.0.2 &&   rm -f build.sh
#12 393.2   CXXLD    libgroonga.la
#12 393.9 ../libtool: cd: line 5164: can't cd to lib: No such file or directory
#12 393.9 libtool:   error: cannot determine absolute directory name of 'lib'
#12 393.9 make[4]: *** [Makefile:1025: libgroonga.la] Error 1
#12 393.9 make[4]: Leaving directory '/build/groonga-14.0.2/lib'
#12 393.9 make[3]: *** [Makefile:1208: all-recursive] Error 1
#12 393.9 make[2]: *** [Makefile:943: all] Error 2
#12 393.9 make[3]: Leaving directory '/build/groonga-14.0.2/lib'
#12 393.9 make[2]: Leaving directory '/build/groonga-14.0.2/lib'
#12 393.9 make[1]: *** [Makefile:659: all-recursive] Error 1
#12 393.9 make[1]: Leaving directory '/build/groonga-14.0.2'
#12 393.9 make: *** [Makefile:538: all] Error 2

Probably, this problem resolve by changing to CMake base build system.

Related issues is #40.

otegami commented 4 months ago

Let me check it!

Before trying the following steps, I will read logs again.

I will try to resolve this issue at the following steps.

otegami commented 4 months ago

Before trying the following steps, I will read logs again.

I will build current docker image to check the ./libtool file.

otegami commented 4 months ago

I'm wait for the build,

$ git diff
diff --git a/alpine/12-slim/Dockerfile b/alpine/12-slim/Dockerfile
index 7593b86..06cd1ad 100644
--- a/alpine/12-slim/Dockerfile
+++ b/alpine/12-slim/Dockerfile
@@ -16,25 +16,25 @@ RUN \
 ENV PGROONGA_VERSION=3.2.0 \
     GROONGA_VERSION=14.0.2

-COPY alpine/build.sh /
-RUN \
-  /build.sh ${PGROONGA_VERSION} ${GROONGA_VERSION} && \
-  rm -f build.sh
+# COPY alpine/build.sh /
+# RUN \
+#   /build.sh ${PGROONGA_VERSION} ${GROONGA_VERSION} && \
+#   rm -f build.sh

-FROM postgres:12-alpine
+# FROM postgres:12-alpine

-# copy thirdpart lib files
-COPY --from=0 /usr/lib/libmsgpack-c.so.? /usr/lib/
-COPY --from=0 /usr/lib/liblz4.so.? /usr/lib/
-COPY --from=0 /usr/lib/libzstd.so.? /usr/lib/
-# copy MeCab files
-COPY --from=0 /usr/local/etc/mecabrc /usr/local/etc/
-COPY --from=0 /usr/local/lib/libmecab.so.? /usr/local/lib/
-COPY --from=0 /usr/local/lib/mecab/ /usr/local/lib/mecab/
-# copy Groonga lib files
-COPY --from=0 /usr/local/etc/groonga/ /usr/local/etc/groonga/
-COPY --from=0 /usr/local/lib/groonga/ /usr/local/lib/groonga/
-COPY --from=0 /usr/local/lib/libgroonga.so.? /usr/local/lib/
-# copy PGroonga extension files
-COPY --from=0 /usr/local/lib/postgresql/pgroonga*.so /usr/local/lib/postgresql/
-COPY --from=0 /usr/local/share/postgresql/extension/pgroonga* /usr/local/share/postgresql/extension/
+# # copy thirdpart lib files
+# COPY --from=0 /usr/lib/libmsgpack-c.so.? /usr/lib/
+# COPY --from=0 /usr/lib/liblz4.so.? /usr/lib/
+# COPY --from=0 /usr/lib/libzstd.so.? /usr/lib/
+# # copy MeCab files
+# COPY --from=0 /usr/local/etc/mecabrc /usr/local/etc/
+# COPY --from=0 /usr/local/lib/libmecab.so.? /usr/local/lib/
+# COPY --from=0 /usr/local/lib/mecab/ /usr/local/lib/mecab/
+# # copy Groonga lib files
+# COPY --from=0 /usr/local/etc/groonga/ /usr/local/etc/groonga/
+# COPY --from=0 /usr/local/lib/groonga/ /usr/local/lib/groonga/
+# COPY --from=0 /usr/local/lib/libgroonga.so.? /usr/local/lib/
+# # copy PGroonga extension files
+# COPY --from=0 /usr/local/lib/postgresql/pgroonga*.so /usr/local/lib/postgresql/
+# COPY --from=0 /usr/local/share/postgresql/extension/pgroonga* /usr/local/share/postgresql/extension/
$ docker build -f alpine/12-slim/Dockerfile \
             -t pgroonga-12-slim \
             .
$ docker run -it \
           --rm \
           --name pgroonga-12-slim \
           -e POSTGRES_DB=pgroonga \
           -e POSTGRES_PASSWORD=pgroonga \
           -e POSTGRES_USER=pgroonga \
           --volume ${PWD}:/host \
           pgroonga-12-slim
$ docker exec -it pgroonga-12-slim bin/bash
# cd host/alpine/
# ./build.sh ${PGROONGA_VERSION} ${GROONGA_VERSION}
otegami commented 4 months ago

The following error is raised. It's the same one. ref: https://github.com/pgroonga/docker/actions/runs/9554591639/job/26335983002

# ./build.sh ${PGROONGA_VERSION} ${GROONGA_VERSION}
  CXXLD    libgroonga.la
../libtool: cd: line 5164: can't cd to lib: No such file or directory
libtool:   error: cannot determine absolute directory name of 'lib'
make[4]: *** [Makefile:1025: libgroonga.la] Error 1
make[4]: Leaving directory '/host/alpine/build/groonga-14.0.2/lib'
make[3]: *** [Makefile:1208: all-recursive] Error 1
make[3]: Leaving directory '/host/alpine/build/groonga-14.0.2/lib'
make[2]: *** [Makefile:943: all] Error 2
make[2]: Leaving directory '/host/alpine/build/groonga-14.0.2/lib'
make[1]: *** [Makefile:659: all-recursive] Error 1
make[1]: Leaving directory '/host/alpine/build/groonga-14.0.2'
make: *** [Makefile:538: all] Error 2
otegami commented 4 months ago

It's because of the msgpack-c's pkgconfig path.

# cat /usr/lib/pkgconfig/msgpack-c.pc
prefix=/usr
exec_prefix=/usr
libdir=lib
includedir=include

Name: MessagePack
Description: Binary-based efficient object serialization library
Version: 6.0.1
Libs: -L${libdir} -lmsgpack-c
Cflags: -I${includedir}
otegami commented 4 months ago

After adding workaround for msgpack-c pkgconfig, It succeeded. I have already made a pull request for fixing this issue for handling path problems. After releasing new version of msgpack-c. it will solve it. ref: https://github.com/msgpack/msgpack-c/pull/1119

$ git diff
diff --git a/alpine/build.sh b/alpine/build.sh
index 3b909bb..64d9a7e 100755
--- a/alpine/build.sh
+++ b/alpine/build.sh
@@ -37,6 +37,7 @@ make -j$(nproc)
 make install
 cd -

+sed -i.bak -E -e 's,^(include|lib)dir=,\1dir=${prefix}/,g' /usr/lib/pkgconfig/msgpack-c.pc
 wget https://packages.groonga.org/source/groonga/groonga-${GROONGA_VERSION}.tar.gz
 tar xf groonga-${GROONGA_VERSION}.tar.gz
 cd groonga-${GROONGA_VERSION}
$ docker build -f alpine/12-slim/Dockerfile \
             -t pgroonga-12-slim \
             .
otegami commented 4 months ago

This change might fix this issue. https://github.com/pgroonga/docker/pull/43

otegami commented 4 months ago

We decided to resolve this issue by changing to CMake base build system. So I will start to do https://github.com/pgroonga/docker/issues/40 at first.