Commit 1e26d1f8 authored by Mathieu Parent's avatar Mathieu Parent

Dockerfile

parent d3f65bbd
Pipeline #520 passed with stage
in 2 minutes and 8 seconds
FROM debian:stretch as builder
COPY . /tmp/build/lemonldap-ng
WORKDIR /tmp/build/lemonldap-ng
RUN set -x && \
echo "Installing build dependencies..." && \
apt-get update && \
apt-get install -y \
build-essential \
&& \
apt-get build-dep -y . && \
\
echo "Converting to native package..." && \
suffix="~wip" && \
sed -i "1{s/-1) /$suffix) /}" debian/changelog && \
sed -i 's/3.0 (quilt)/3.0 (native)/' debian/source/format && \
\
echo "Building LemonLDAP..." && \
dpkg-buildpackage && \
\
echo "Cleaning up..." && \
rm -rf /var/lib/apt/lists/*
# =================================================================
FROM debian:stretch
ENV SSODOMAIN=example.com
COPY docker-entrypoint.sh /
COPY --from=builder /tmp/build/*.deb /tmp/build/
RUN set -x && \
echo "Installing..." && \
apt-get update && \
apt-get install -y \
apache2 \
dumb-init \
libapache2-mod-perl2 \
libapache2-mod-fcgid \
/tmp/build/*.deb \
&& \
\
echo "Changing SSO Domain" && \
sed -i "s/example\.com/${SSODOMAIN}/g" \
/etc/lemonldap-ng/* \
#/var/lib/lemonldap-ng/conf/lmConf-1.js \
/var/lib/lemonldap-ng/test/index.pl && \
\
echo "Enabling sites..." && \
a2ensite handler-apache2.conf && \
a2ensite portal-apache2.conf && \
a2ensite manager-apache2.conf && \
a2ensite test-apache2.conf && \
a2enmod fcgid perl alias rewrite && \
mkdir /vhosts && \
\
echo "Cleaning up..." && \
rm -rf /tmp/build && \
rm -rf /tmp/lemonldap-ng-config && \
rm -rf /var/lib/apt/lists/*
VOLUME /var/lib/lemonldap-ng/conf
EXPOSE 80 443
ENTRYPOINT ["dumb-init","--","/docker-entrypoint.sh"]
CMD "/usr/sbin/apache2ctl" "-D" "FOREGROUND"
#!/bin/bash
usage() {
echo "$0 features:" >&2
echo ' - Use $SSODOMAIN environment variable to set ServerName' >&2
echo ' - Enable all Apache and nginx vhosts (sites-available)' >&2
echo ' - Enable all Apache vhosts from /vhosts' >&2
echo ' - (if $FASTCGI_PASS is set) Update auth_url' >&2
echo ' - (if needed) setup llng-fastcgi-server envs and dirs
echo '' >&2
echo 'Suggested commands:' >&2
echo ' /usr/sbin/apache2ctl -D FOREGROUND # (default)' >&2
echo ' /usr/sbin/nginx -g "daemon off;"' >&2
echo ' /usr/sbin/llng-fastcgi-server --foreground --listen 127.0.0.1:9000' >&2
}
if [ "$1" = '--help' ]; then
usage
exit 1
fi
if [ "$SSODOMAIN" != 'example.com' ]; then
echo "Using ServerName: $SSODOMAIN"
fi
echo "ServerName $SSODOMAIN" >> /etc/apache2/apache2.conf
sed -i "s/example\.com/${SSODOMAIN}/g" /etc/lemonldap-ng/* \
/var/lib/lemonldap-ng/conf/lmConf-1.js* /var/lib/lemonldap-ng/test/index.pl
find /etc/apache2/sites-available/ -name '*.conf' ! -name '000-default.conf' \
-exec ln -sf {} /etc/apache2/sites-enabled/ \;
find /etc/nginx/sites-available/ -name '*.conf' \
-exec ln -sf {} /etc/nginx/sites-enabled/ \;
find /vhosts/ -name '*.conf' \
-exec ln -sf {} /etc/apache2/sites-enabled/ \;
if [ -n "$FASTCGI_PASS" ]; then
sed -i "s@unix:/var/run/llng-fastcgi-server/llng-fastcgi.sock@${FASTCGI_PASS}/g" /etc/lemonldap-ng/*
fi
if [ "$1" = /usr/sbin/llng-fastcgi-server ]; then
# Setup like lemonldap-ng-fastcgi-server.service
. /etc/default/lemonldap-ng-fastcgi-server
export SOCKET
export PID
export USER
export GROUP
mkdir -p "$(dirname "$PID")"
chown "$USER" "$(dirname "$PID")"
fi
exec "$@"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment