diff --git a/Dockerfile b/Dockerfile index 9f90aef..4a32d9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,45 @@ -FROM quay.io/natlibfi/usemarcon:3 -ENTRYPOINT ["bin/yazproxy", "-c", "/conf/conf.xml", "@:8080"] +FROM alpine:3 as builder-dep + +ARG YAZ_REF=master +ARG YAZPP_REF=master +ARG USEMARCON_REF=master -USER root -COPY . /build/yazproxy WORKDIR /build +RUN apk -U --no-cache add sudo git build-base automake autoconf libtool bison tcl-dev icu-dev gnutls-dev libxslt-dev libxml2-dev libgpg-error-dev libgcrypt-dev file \ + && git clone https://github.com/indexdata/yaz && cd yaz && git checkout $YAZ_REF \ + && ./buildconf.sh && ./configure --prefix=/yaz && make install-exec \ + && cd .. \ + && git clone https://github.com/indexdata/yazpp && cd yazpp && git checkout $YAZPP_REF \ + && ./buildconf.sh && ./configure --prefix=/yaz && make install-exec \ + && cd .. \ + && git clone https://github.com/indexdata/usemarcon && cd usemarcon && git checkout $USEMARCON_REF \ + && cd pcre && chmod +x CleanTxt config.guess config.sub configure depcomp Detrail install-sh perltest.pl PrepareRelease RunGrepTest RunTest 132html \ + && ./configure --enable-utf8 --enable-unicode-properties --disable-shared --disable-cpp && make \ + && cd .. \ + && ./buildconf.sh && ./configure --prefix=/yaz && make install-exec + +FROM builder-dep as builder + +COPY . /build/yazproxy + +WORKDIR /build/yazproxy + +RUN ./buildconf.sh && ./configure --prefix=/yaz --with-usemarcon=/yaz && make install-exec + +FROM alpine:3 +ENTRYPOINT ["/yaz/entrypoint.sh"] + +ENV PORT 10210 +ENV CONF /conf/conf.xml + +COPY --from=builder /yaz /yaz +COPY docker-entrypoint.sh /yaz/entrypoint.sh + RUN apk -U --no-cache add libxslt libxml2 libgcrypt libgpg-error icu gnutls \ - && apk -U --no-cache add --virtual .build-deps g++ sudo git make automake \ - autoconf libtool bison tcl-dev icu-dev gnutls-dev libxslt-dev libxml2-dev \ - libgpg-error-dev libgcrypt-dev \ - && addgroup -S yaz && adduser -S -h /yaz yaz yaz \ - && chown -R yaz:yaz /build \ - && sudo -u yaz sh -c 'cd /build \ - && git clone https://github.com/indexdata/yaz && cd yaz \ - && ./buildconf.sh && ./configure --prefix=/yaz' \ - && sh -c 'cd yaz && make install-exec' \ - && sudo -u yaz sh -c 'cd /build \ - && git clone https://github.com/indexdata/yazpp && cd yazpp \ - && ./buildconf.sh && ./configure --prefix=/yaz' \ - && sh -c 'cd yazpp && make install-exec' \ - && sudo -u yaz sh -c 'cd /build/yazproxy && ./buildconf.sh \ - && ./configure --prefix=/yaz --with-usemarcon=/usemarcon' \ - && sh -c 'cd yazproxy && make install-exec && chown -R yaz:yaz /yaz' \ - && apk del .build-deps \ - && rm -rf /build tmp/* /var/cache/apk/* + && addgroup -S yaz \ + && adduser -S -h /yaz yaz yaz \ + && chown -R yaz:yaz /yaz WORKDIR /yaz -USER yaz +USER yaz \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..06dee8b --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/sh +if [ $# -eq 0 ];then + exec bin/yazproxy -c $CONF @:$PORT +else + exec bin/yazproxy $@ +fi \ No newline at end of file