Skip to content

Service fails to start when building the image using the official Dockerfile with default configuration #288

@joebnb

Description

@joebnb

Hello, I'm building an openresty image with brotli support using the script below.
My environment is macOS, and I'm using docker buildx --platform for cross-architecture builds (the service will run in kubernetes on Linux).

The image builds successfully without any errors, but when starting the container I get the following runtime error:

+ nginx -g 'daemon off;'
Error loading shared library libgcc_s.so.1: No such file or directory (needed by /usr/local/openresty/luajit/lib/libluajit-5.1.so.2)
Error relocating /usr/local/openresty/luajit/lib/libluajit-5.1.so.2: __deregister_frame: symbol not found
Error relocating /usr/local/openresty/luajit/lib/libluajit-5.1.so.2: _Unwind_GetIP: symbol not found
Error relocating /usr/local/openresty/luajit/lib/libluajit-5.1.so.2: _Unwind_GetCFA: symbol not found
Error relocating /usr/local/openresty/luajit/lib/libluajit-5.1.so.2: _Unwind_SetGR: symbol not found
Error relocating /usr/local/openresty/luajit/lib/libluajit-5.1.so.2: __register_frame: symbol not found
Error relocating /usr/local/openresty/luajit/lib/libluajit-5.1.so.2: _Unwind_SetIP: symbol not found
Error relocating /usr/local/openresty/luajit/lib/libluajit-5.1.so.2: _Unwind_RaiseException: symbol not found
Error relocating /usr/local/openresty/luajit/lib/libluajit-5.1.so.2: _Unwind_DeleteException: symbol not found

I also tried building the official OpenResty image directly from https://github.com/openresty/docker-openresty/blob/master/noble/Dockerfile without any modifications, it's also throw upper error.

And i found an issue #5 mentioning that libgcc is required at runtime
so I added it:

RUN apk add --no-cache zlib pcre openssl libgcc

however, the problem still persists.

could give me some advise how to fix this?


Build command and dockerfile:

docker buildx build --platform linux/amd64 -t openresty-brotli .
### -------- Stage 1: build openresty + brotli --------
FROM openresty/openresty:alpine-fat AS builder

RUN apk add --no-cache git g++ make cmake zlib-dev pcre-dev openssl-dev perl wget

# clone brotli module
RUN git clone https://github.com/google/ngx_brotli.git /tmp/ngx_brotli \
    && cd /tmp/ngx_brotli && git submodule update --init --recursive

# **** build brotli library ****
RUN cd /tmp/ngx_brotli/deps/brotli && mkdir out \
    && cd out \
    && cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF .. \
    && make -j$(nproc)

# download openresty src
RUN cd /tmp \
    && wget https://openresty.org/download/openresty-1.27.1.2.tar.gz \
    && tar zxvf openresty-1.27.1.2.tar.gz

# build openresty with brotli
RUN cd /tmp/openresty-1.27.1.2 \
    && ./configure \
    --with-compat \
    --with-pcre-jit \
    --add-module=/tmp/ngx_brotli \
    && make -j$(nproc) \
    && make install

### -------- Stage 2: minimal runtime --------
FROM openresty/openresty:alpine

RUN apk add --no-cache zlib pcre openssl libgcc

COPY --from=builder /usr/local/openresty/ /usr/local/openresty/

ENV PATH="/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin:${PATH}"

CMD ["nginx", "-g", "daemon off;"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions