Debian Codegraph @

.ci/docker/Dockerfile

raw
1 FROM debian:bullseye-slim
2 LABEL maintainer="[email protected]"
3
4 # Create group and user
5 RUN groupadd -g 2000 ldap && useradd -m -u 2001 -g ldap ldap
6
7 RUN DEBIAN_FRONTEND=noninteractive apt update && apt upgrade -y
8 RUN DEBIAN_FRONTEND=noninteractive apt install -y \
9 # For service tests and setting network delay
10 procps iproute2 \
11 # OpenLDAP server and utils.
12 slapd ldap-utils libsasl2-modules-gssapi-mit sasl2-bin openssl \
13 # Kerberos server and utils.
14 krb5-admin-server krb5-kdc krb5-user \
15 # Supervisor and Python 3
16 supervisor python3
17
18 RUN chown -Rf ldap:ldap /etc/ldap/ /var/lib/ldap /var/lib/krb5kdc && chmod o+w /var/log/
19
20 USER ldap
21
22 # Setting Kerberos
23 COPY --chown=ldap:ldap ./.ci/krb5/kdc.conf ./.ci/krb5/kadm5.acl /etc/krb5kdc/
24 COPY --chown=ldap:ldap ./.ci/krb5/krb5.conf /etc/krb5.conf
25
26 # Copy the root CA cert and key.
27 COPY --chown=ldap:ldap ./tests/testenv/certs/cacert.pem /etc/ldap/certs/cacert.pem
28 COPY --chown=ldap:ldap ./tests/testenv/certs/cacert.key /home/ldap/cacert.key
29 # Copy client cert and key.
30 COPY --chown=ldap:ldap ./tests/testenv/certs/client.pem \
31 ./tests/testenv/certs/client.key \
32 /home/ldap/
33
34 # Generate server cert.
35 RUN openssl genrsa -out /etc/ldap/certs/server.key 2048 && \
36 openssl req -new -key /etc/ldap/certs/server.key -out /home/ldap/server.csr -subj "/C=XX/CN=bonsai.test" && \
37 openssl x509 -req -days 500 -in /home/ldap/server.csr -CA /etc/ldap/certs/cacert.pem \
38 -CAkey /home/ldap/cacert.key -CAcreateserial -out /etc/ldap/certs/server.pem -sha256
39
40 # Copy the basic LDIF files and test.jpeg into the container.
41 COPY ./tests/testenv/ldifs/base.ldif \
42 ./tests/testenv/ldifs/users.ldif \
43 ./tests/testenv/ldifs/settings.ldif \
44 ./tests/testenv/ldifs/overlays.ldif \
45 ./tests/testenv/ldifs/ppolicy.ldif \
46 ./tests/testenv/ldifs/referrals.ldif \
47 ./tests/testenv/ldifs/schema.ldif \
48 ./tests/testenv/test.jpeg \
49 /home/ldap/
50
51 COPY ./.ci/docker/start_slapd.sh /home/ldap/start_slapd.sh
52
53 RUN mkdir /home/ldap/run
54 VOLUME /home/ldap/run
55
56 USER root
57
58 # Set ownership and access rights for certs.
59 RUN chown -R ldap:ldap /etc/ldap/certs/ && chmod 644 /etc/ldap/certs/*
60
61 # Open LDAP, LDAPS, Kerberos and delay script ports.
62 EXPOSE 389 636 88 749 8000
63
64 COPY ./.ci/delay.py /root/delay.py
65 COPY ./.ci/docker/supervisord.conf /etc/supervisord.conf
66
67 COPY ./.ci/docker/entrypoint.sh /root/entrypoint.sh
68 RUN chmod +x /root/entrypoint.sh
69 RUN chmod +x /home/ldap/start_slapd.sh
70
71 ENTRYPOINT ["/root/entrypoint.sh"]
72 CMD ["supervisord", "-c", "/etc/supervisord.conf"]