Skip to content

Commit c8078ee

Browse files
committed
Change container to a init container
1 parent 7607272 commit c8078ee

4 files changed

Lines changed: 24 additions & 116 deletions

File tree

Dockerfile

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:7.1-apache
1+
FROM debian:buster-slim
22

33
MAINTAINER zsx <thinkernel@gmail.com>
44

@@ -8,38 +8,21 @@ ENV LAM_PACKAGE ldap-account-manager-${LAM_VERSION}
88
# Install the software that lam environment requires
99
RUN apt-get update && apt-get install -y \
1010
bzip2 \
11-
libfreetype6-dev \
12-
libjpeg62-turbo-dev \
13-
libldap2-dev \
14-
libmagickwand-dev \
15-
libpng12-dev --no-install-recommends \
16-
&& rm -rf /var/lib/apt/lists/* \
17-
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ \
18-
--with-jpeg-dir=/usr/include/ \
19-
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
20-
&& docker-php-ext-install gettext gd ldap zip
21-
22-
RUN pecl install imagick && docker-php-ext-enable imagick
23-
24-
ENV LDAP_URL ldap://localhost
25-
ENV LDAP_PORT 389
26-
ENV LDAP_DN example.com
27-
ENV USER_DN ou=people,dc=example,dc=com
28-
ENV GROUP_DN ou=group,dc=example,dc=com
29-
30-
# Install ldap-account-manager package
31-
RUN curl https://nchc.dl.sourceforge.net/project/lam/LAM/${LAM_VERSION}/${LAM_PACKAGE}.tar.bz2 \
32-
-o ${LAM_PACKAGE}.tar.bz2 \
11+
curl \
12+
ca-certificates \
13+
--no-install-recommends \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
# Download ldap-account-manager package
17+
RUN curl -fSsL \
18+
https://phoenixnap.dl.sourceforge.net/project/lam/LAM/${LAM_VERSION}/${LAM_PACKAGE}.tar.bz2 \
19+
-o ${LAM_PACKAGE}.tar.bz2 \
3320
&& bzip2 -d ${LAM_PACKAGE}.tar.bz2 \
34-
&& tar xf ${LAM_PACKAGE}.tar -C /var/www/html \
35-
&& rm -f ${LAM_PACKAGE}.tar \
36-
&& mv /var/www/html/${LAM_PACKAGE} /var/www/html/lam
21+
&& tar xf ${LAM_PACKAGE}.tar -C /var/lib \
22+
&& rm -f ${LAM_PACKAGE}.tar
3723

38-
COPY lam.conf.default /var/www/html/lam/
3924
COPY setup.sh /usr/local/bin/setup.sh
4025

41-
RUN chown -R www-data:www-data /var/www/html/lam
42-
43-
VOLUME /var/www/html/lam/config
26+
VOLUME /var/lib/ldap-account-manager/config
4427

45-
CMD ["setup.sh"]
28+
CMD ["/usr/local/bin/setup.sh"]

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
# docker-lam
1+
# ldap-account-manager init container
2+
3+
This is a container for initializing the config volume of ldapaccountmanager/lam
4+
https://github.com/LDAPAccountManager/lam/issues/124

lam.conf.default

Lines changed: 0 additions & 68 deletions
This file was deleted.

setup.sh

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
#!/bin/bash
22
set -e
33

4-
LAM_CONF_FILE=/var/www/html/lam/config/lam.conf
4+
LAM_CONF_PATH=/var/lib/ldap-account-manager/config
55

6-
: ${LDAP_URL:=ldap://openldap}
7-
: ${LDAP_PORT:=389}
8-
: ${SLAPD_DN:=dc=example,dc=com}
9-
: ${LDAP_ADMIN:=cn=admin,dc=example,dc=com}
10-
: ${USER_DN:=ou=people,dc=example,dc=com}
11-
: ${GROUP_DN:=ou=group,dc=example,dc=com}
12-
13-
if [ ! -f "$LAM_CONF_FILE" ]; then
14-
sed -e "s#serverURL: ldap://localhost:389#ServerURL: ${LDAP_URL}:${LDAP_PORT}#g" /var/www/html/lam/lam.conf.default > ${LAM_CONF_FILE}
15-
sed -i "s/admins: cn=Manager,dc=my-domain,dc=com/Admins: ${LDAP_ADMIN}/g" ${LAM_CONF_FILE}
16-
sed -i "s/treesuffix: dc=yourdomain,dc=org/treesuffix: ${SLAPD_DN}/g" ${LAM_CONF_FILE}
17-
sed -i "s/types: suffix_user: ou=People,dc=my-domain,dc=com/types: suffix_user: ${USER_DN}/g" ${LAM_CONF_FILE}
18-
sed -i "s/types: suffix_group: ou=group,dc=my-domain,dc=com/types: suffix_group: ${GROUP_DN}/g" ${LAM_CONF_FILE}
6+
if [ -z "$(ls -A ${LAM_CONF_PATH})" ]; then
7+
cp -r /var/lib/${LAM_PACKAGE}/config/. "${LAM_CONF_PATH}"
8+
cp "${LAM_CONF_PATH}/config.cfg.sample" "${LAM_CONF_PATH}/config.cfg"
9+
cp "${LAM_CONF_PATH}/addressbook.conf.sample" "${LAM_CONF_PATH}/lam.conf"
10+
chown -R www-data:www-data "${LAM_CONF_PATH}"
1911
fi
20-
21-
exec /usr/local/bin/apache2-foreground

0 commit comments

Comments
 (0)