Skip to content

Add support for nss_wrapper to the Alpine based images #543

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion 11/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ ENV PG_MAJOR 11
ENV PG_VERSION 11.1
ENV PG_SHA256 90815e812874831e9a4bf6e1136bf73bc2c5a0464ef142e2dfea40cda206db08

ARG NSS_WRAPPER_VERSION=1.1.5

RUN set -ex \
\
&& apk add --no-cache --virtual .fetch-deps \
Expand Down Expand Up @@ -120,14 +122,26 @@ RUN set -ex \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)" \
# Add nss_wrapper
&& echo -e "#ifndef NSS__H\n#define NSS__H\n\nenum nss_status\n{\n\tNSS_STATUS_TRYAGAIN = -2,\n\tNSS_STATUS_UNAVAIL = -1,\n\tNSS_STATUS_NOTFOUND = 0,\n\tNSS_STATUS_SUCCESS = 1,\n\tNSS_STATUS_RETURN = 2\n};\n\n#endif" > /usr/local/include/nss.h \
&& apk add --no-cache --virtual .nss_wrapper-build-deps build-base cmake cmocka-dev \
&& wget -O- https://ftp.samba.org/pub/cwrap/nss_wrapper-${NSS_WRAPPER_VERSION}.tar.gz | tar xzf - \
&& mkdir nss_wrapper-${NSS_WRAPPER_VERSION}/build && \
(cd nss_wrapper-${NSS_WRAPPER_VERSION}/build \
&& cmake .. -DUNIT_TESTING:BOOL=ON \
&& make -j "$(nproc)" \
&& make -j "$(nproc)" CTEST_OUTPUT_ON_FAILURE=TRUE test \
&& make install) \
&& ln -s /usr/local/lib/libnss_wrapper.so /usr/lib/libnss_wrapper.so \
&& rm -rf nss_wrapper-${NSS_WRAPPER_VERSION} /usr/local/include/nss.h \
&& apk add --no-cache --virtual .postgresql-rundeps \
$runDeps \
bash \
su-exec \
# tzdata is optional, but only adds around 1Mb to image size and is recommended by Django documentation:
# https://docs.djangoproject.com/en/1.10/ref/databases/#optimizing-postgresql-s-configuration
tzdata \
&& apk del .fetch-deps .build-deps \
&& apk -q del .fetch-deps .build-deps .nss_wrapper-build-deps\
&& cd / \
&& rm -rf \
/usr/src/postgresql \
Expand Down
17 changes: 16 additions & 1 deletion Dockerfile-alpine.template
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ ENV PG_MAJOR %%PG_MAJOR%%
ENV PG_VERSION %%PG_VERSION%%
ENV PG_SHA256 %%PG_SHA256%%

# ARG NSS_WRAPPER_VERSION=%%NSS_WRAPPER_VERSION%%
ARG NSS_WRAPPER_VERSION=1.1.5

%%OSSP_UUID_ENV_VARS%%
RUN set -ex \
\
Expand Down Expand Up @@ -116,6 +119,18 @@ RUN set -ex \
&& make install-world \
&& make -C contrib install \
\
# Add nss_wrapper
&& echo -e "#ifndef NSS__H\n#define NSS__H\n\nenum nss_status\n{\n\tNSS_STATUS_TRYAGAIN = -2,\n\tNSS_STATUS_UNAVAIL = -1,\n\tNSS_STATUS_NOTFOUND = 0,\n\tNSS_STATUS_SUCCESS = 1,\n\tNSS_STATUS_RETURN = 2\n};\n\n#endif" > /usr/local/include/nss.h \
&& apk add --no-cache --virtual .nss_wrapper-build-deps build-base cmake cmocka-dev \
&& wget -O- https://ftp.samba.org/pub/cwrap/nss_wrapper-${NSS_WRAPPER_VERSION}.tar.gz | tar xzf - \
&& mkdir nss_wrapper-${NSS_WRAPPER_VERSION}/build && \
(cd nss_wrapper-${NSS_WRAPPER_VERSION}/build \
&& cmake .. -DUNIT_TESTING:BOOL=ON \
&& make -j "$(nproc)" \
&& make -j "$(nproc)" CTEST_OUTPUT_ON_FAILURE=TRUE test \
&& make install) \
&& ln -s /usr/local/lib/libnss_wrapper.so /usr/lib/libnss_wrapper.so \
&& rm -rf nss_wrapper-${NSS_WRAPPER_VERSION} /usr/local/include/nss.h \
&& runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
| tr ',' '\n' \
Expand All @@ -129,7 +144,7 @@ RUN set -ex \
# tzdata is optional, but only adds around 1Mb to image size and is recommended by Django documentation:
# https://docs.djangoproject.com/en/1.10/ref/databases/#optimizing-postgresql-s-configuration
tzdata \
&& apk del .fetch-deps .build-deps \
&& apk del .fetch-deps .build-deps .nss_wrapper-build-deps \
&& cd / \
&& rm -rf \
/usr/src/postgresql \
Expand Down