openresty / openresty/docker-openresty

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

Open
#288 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Dockerfile
Stars
1k
Forks
536
Avg merge
1d 32m
Merged PRs (30d)
1

Description

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 https://github.com/openresty/docker-openresty/issues/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;"]

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the official noble/Dockerfile and the two-stage Dockerfile in the report, then reproduce the failure with docker buildx build --platform linux/amd64. Check the runtime dependencies of /usr/local/openresty/luajit/lib/libluajit-5.1.so.2 and verify the image starts with the default configuration without the reported libgcc_s.so.1 errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker
Domain
devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.