Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpine linux build fails #20

Open
olimsaidov opened this issue Jan 31, 2017 · 3 comments
Open

Alpine linux build fails #20

olimsaidov opened this issue Jan 31, 2017 · 3 comments

Comments

@olimsaidov
Copy link

How can I build this repo in docker official alpine based postgres image. I am getting compile error:

gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fpic -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2   -c -o src/librabbitmq/amqp_socket.o src/librabbitmq/amqp_socket.c
In file included from src/librabbitmq/amqp_socket.c:10:0:
src/librabbitmq/amqp.h:177:36: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration
                             struct timeval *timeout);
                                    ^~~~~~~
src/librabbitmq/amqp_socket.c:23:5: error: conflicting types for 'amqp_open_socket'
 int amqp_open_socket(char const *hostname,
     ^~~~~~~~~~~~~~~~
In file included from src/librabbitmq/amqp_socket.c:10:0:
src/librabbitmq/amqp.h:176:12: note: previous declaration of 'amqp_open_socket' was here
 extern int amqp_open_socket(char const *hostname, int portnumber,
            ^~~~~~~~~~~~~~~~
make: *** [<builtin>: src/librabbitmq/amqp_socket.o] Error 1

Dockerfile content:

FROM postgres:9-alpine

RUN apk update && \
    apk add git alpine-sdk && \
    git clone https://github.com/omniti-labs/pg_amqp.git /tmp/pg_ampq && \
    cd /tmp/pg_ampq && \
    make && make install
@inbarbarkai
Copy link

inbarbarkai commented Nov 27, 2019

Hey,
This works for me.
Added include to types.h:

FROM postgres:12-alpine as builder

RUN apk update && apk add git make gcc linux-headers libc-dev libxml2-dev alpine-sdk musl-dev
RUN git clone https://github.com/omniti-labs/pg_amqp.git workdir

ARG AMQP_H=src/librabbitmq/amqp.h

RUN cd workdir \
        && head -n 2 ${AMQP_H} > ${AMQP_H}.temp \
        && echo "#include <sys/types.h>" >>  ${AMQP_H}.temp \
        && cat ${AMQP_H} | sed -e '1,3d' >> ${AMQP_H}.temp \
        && mv ${AMQP_H}.temp ${AMQP_H}

RUN cd workdir && make && make install


FROM postgres:12-alpine
COPY --from=builder /usr/local/lib/postgresql/pg_amqp.so /usr/local/lib/postgresql/pg_amqp.so
COPY --from=builder /usr/local/share/postgresql/extension /usr/local/share/postgresql/extension
COPY --from=builder /usr/local/share/doc/postgresql/extension /usr/local/share/doc/postgresql/extension
RUN chmod 755 /usr/local/lib/postgresql/pg_amqp.so \
        && chmod 644 /usr/local/share/postgresql/extension/amqp.control \
        && chmod 644 /usr/local/share/postgresql/extension/amqp--0.3.0--0.4.0.sql \
        && chmod 644 /usr/local/share/postgresql/extension/amqp--0.4.0--0.4.1.sql \
        && chmod 644 /usr/local/share/postgresql/extension/amqp--0.4.2.sql \
        && chmod 777 /usr/local/share/postgresql/extension/

I know that 777 is not recommended but it was for my local testing.

@sohrabq
Copy link

sohrabq commented Nov 15, 2022

Hello, having the same issue and same error. @inbarbarkai even tried to run your dockerfile still the same error and terminate docker execution.

@milinbhakta
Copy link

@sohrabq Here is a updated docker with the latest alpine version.

# Docker file for postgres with pg_amqp extension installed and configured to use RabbitMQ

FROM postgres:alpine

RUN apk update && apk add git make gcc linux-headers libc-dev libxml2-dev alpine-sdk musl-dev postgresql-dev rabbitmq-c-dev
RUN git clone https://github.com/omniti-labs/pg_amqp.git workdir

ARG AMQP_H=src/librabbitmq/amqp.h

RUN cd workdir \
    && head -n 2 ${AMQP_H} > ${AMQP_H}.temp \
    && echo "#include <sys/types.h>" >>  ${AMQP_H}.temp \
    && cat ${AMQP_H} | sed -e '1,3d' >> ${AMQP_H}.temp \
    && mv ${AMQP_H}.temp ${AMQP_H}

RUN cd workdir && make && make install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants