EarthScope / ringserver

Apache License 2.0
31 stars 17 forks source link

Docker container does not compile #45

Closed timronan closed 3 months ago

timronan commented 12 months ago

docker build . does not generate a docker image. The DockerFile Command RUN cd /build && CFLAGS="-O2" make fails with the error output below:

...
7.221 Running make all in src
7.223 make[1]: Entering directory `/build/src'
7.223 cc -O2 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -I../libmseed -I../mxml -I../pcre    -c -o stack.o stack.c
7.254 cc -O2 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -I../libmseed -I../mxml -I../pcre    -c -o rbtree.o rbtree.c
7.318 cc -O2 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -I../libmseed -I../mxml -I../pcre    -c -o logging.o logging.c
7.381 cc -O2 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -I../libmseed -I../mxml -I../pcre    -c -o clients.o clients.c
7.513 cc -O2 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -I../libmseed -I../mxml -I../pcre    -c -o slclient.o slclient.c
7.754 cc -O2 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -I../libmseed -I../mxml -I../pcre    -c -o dlclient.o dlclient.c
7.889 cc -O2 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -I../libmseed -I../mxml -I../pcre    -c -o http.o http.c
8.079 cc -O2 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -I../libmseed -I../mxml -I../pcre    -c -o dsarchive.o dsarchive.c
8.190 cc -O2 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -I../libmseed -I../mxml -I../pcre    -c -o mseedscan.o mseedscan.c
8.310 cc -O2 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -I../libmseed -I../mxml -I../pcre    -c -o generic.o generic.c
8.352 cc -O2 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -I../libmseed -I../mxml -I../pcre    -c -o ring.o ring.c
8.566 cc -O2 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -I../libmseed -I../mxml -I../pcre    -c -o ringserver.o ringserver.c
8.827 cc -O2 -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -I../libmseed -I../mxml -I../pcre  -o ../ringserver stack.o rbtree.o logging.o clients.o slclient.o dlclient.o http.o dsarchive.o mseedscan.o generic.o ring.o ringserver.o  ../pcre/.libs/libpcre.a ../libmseed/libmseed.a ../mxml/libmxml.a -lpthread
8.828 cc: error: ../pcre/.libs/libpcre.a: No such file or directory
8.828 make[1]: *** [ringserver] Error 1
8.828 make[1]: Leaving directory `/build/src'
8.830 make: *** [all] Error 2
------
Dockerfile:20
--------------------
  18 |     # Build executable
  19 |     COPY . /build
  20 | >>> RUN cd /build && CFLAGS="-O2" make
  21 |     
  22 |     # Build ringserver container
--------------------
ERROR: failed to solve: process "/bin/sh -c cd /build && CFLAGS=\"-O2\" make" did not complete successfully: exit code: 2

It seems like the makefile is failing during the cleanup process because the relative ../pcre/.libs/libpcre.a cannot be found within the partially compiled docker image (https://github.com/EarthScope/ringserver/blob/main/src/Makefile#L16). Potentially, the pcre dependency is not being made.

The makefile works when compiling a Ringserver within a virtual machine, and this issue is specific to compiling Docker Images using the DockerFile included in this repository.

matt-c-earthscope commented 8 months ago

I took the approach of switching the base to debian:bookworm-slim and starting debugging from there since centos:7 is EOL.

The line

8.828 cc: error: ../pcre/.libs/libpcre.a: No such file or directory

is a bit of a red herring as this project includes its own copy of the pcre library, so installing the Debian libpcre3-dev doesn't help. The issue seems to be higher up in the output with not being able to compile the local pcre library:

4.390 Running make all in pcre
4.395 make[1]: Entering directory '/build/pcre'
4.395 CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash /build/pcre/missing aclocal-1.16 -I m4
4.397 /build/pcre/missing: line 81: aclocal-1.16: command not found
4.401 WARNING: 'aclocal-1.16' is missing on your system.
4.401          You should only need it if you modified 'acinclude.m4' or
4.401          'configure.ac' or m4 files included by 'configure.ac'.
4.401          The 'aclocal' program is part of the GNU Automake package:
4.401          <https://www.gnu.org/software/automake>
4.401          It also requires GNU Autoconf, GNU m4 and Perl in order to run:
4.401          <https://www.gnu.org/software/autoconf>
4.401          <https://www.gnu.org/software/m4/>
4.401          <https://www.perl.org/>
4.401 make[1]: *** [Makefile:1438: aclocal.m4] Error 127
4.401 make[1]: Leaving directory '/build/pcre'

Installing the automake package in addition to build-essential resolves this. MR coming including change to Debian as the base.

timronan commented 8 months ago

This branch works as expected:

docker build .
docker run -dit -p 18000 IMAGE_ID
docker ps
slinktool -Q -v IP:Port (Found using docker ps in PORTS column)

Returns:

slinktool version: 4.3
[0.0.0.0:62434] network socket opened
[0.0.0.0:62434] connected to: SeedLink v3.1 (2020.075 RingServer) 
[0.0.0.0:62434] capabilities: SLPROTO:3.1 CAP EXTREPLY NSWILDCARD BATCH WS:13
[0.0.0.0:62434] organization: Ring Server
[0.0.0.0:62434] requesting INFO level STREAMS
2024.052.09:46:01.1, seq 0, Received Info (terminated) blockette
[0.0.0.0:62434] network socket closed
chad-earthscope commented 8 months ago

Installing the automake package in addition to build-essential resolves this. MR coming including change to Debian as the base.

Even this shouldn't be needed. The fundamental problem is one of time stamps of files getting modified and triggering autoconf to think it needs to be re-run, which it does not. It doesn't hurt to run automake again, but it could be avoided entirely. I'll see if I can something to #47 to address this.

timronan commented 3 months ago

Closed with PR #53.