Skip to content
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

Clean restart #12

Merged
merged 8 commits into from
Mar 19, 2018
Merged
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
24 changes: 17 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ ENV APACHEDS_VERSION 2.0.0-M24
ENV APACHEDS_ARCH amd64

ENV APACHEDS_ARCHIVE apacheds-${APACHEDS_VERSION}-${APACHEDS_ARCH}.deb
ENV APACHEDS_DATA /var/lib/apacheds-${APACHEDS_VERSION}
ENV APACHEDS_DATA /var/lib/apacheds
ENV APACHEDS_USER apacheds
ENV APACHEDS_GROUP apacheds

RUN ln -s ${APACHEDS_DATA}-${APACHEDS_VERSION} ${APACHEDS_DATA}
VOLUME ${APACHEDS_DATA}

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections \
Expand All @@ -38,11 +39,9 @@ EXPOSE 10389 10636 60088 60464 8080 8443
ENV APACHEDS_INSTANCE default
ENV APACHEDS_BOOTSTRAP /bootstrap

ENV APACHEDS_SCRIPT run.sh
ENV APACHEDS_CMD /${APACHEDS_SCRIPT}
ADD scripts/${APACHEDS_SCRIPT} ${APACHEDS_CMD}
RUN chown ${APACHEDS_USER}:${APACHEDS_GROUP} ${APACHEDS_CMD} \
&& chmod u+rx ${APACHEDS_CMD}
ADD scripts/run.sh /run.sh
RUN chown ${APACHEDS_USER}:${APACHEDS_GROUP} /run.sh \
&& chmod u+rx /run.sh

ADD instance/* ${APACHEDS_BOOTSTRAP}/conf/
ADD ome.ldif ${APACHEDS_BOOTSTRAP}/
Expand All @@ -52,8 +51,19 @@ RUN mkdir ${APACHEDS_BOOTSTRAP}/cache \
&& mkdir ${APACHEDS_BOOTSTRAP}/partitions \
&& chown -R ${APACHEDS_USER}:${APACHEDS_GROUP} ${APACHEDS_BOOTSTRAP}

RUN apt-get install -y python-ldap
ADD bin/ldapmanager /usr/local/bin/ldapmanager

#############################################
# ApacheDS wrapper command
#############################################

CMD ${APACHEDS_CMD}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is removed do you still need the configurability provided by ENV APACHEDS_CMD ENV APACHEDS_SCRIPT: https://github.com/openmicroscopy/apacheds-docker/pull/12/files#diff-3254677a7917c6c01f55212f86c57fbfL41 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't get the syntax right to put the environment variable as the entrypoint (at least not without reverting to bash -c. I'll drop the rest.

# Correct for hard-coded INSTANCES_DIRECTORY variable
RUN sed -i "s#/var/lib/apacheds-${APACHEDS_VERSION}#/var/lib/apacheds#" /opt/apacheds-${APACHEDS_VERSION}/bin/apacheds


RUN curl -L -o /usr/local/bin/dumb-init \
https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64 && \
chmod +x /usr/local/bin/dumb-init

ENTRYPOINT ["/run.sh"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The project sources can be found on [GitHub](https://github.com/openmicroscopy/a

## Installation

The folder */var/lib/apacheds-${APACHEDS_VERSION}* contains the runtime data and thus has been defined as a volume. A [volume container](https://docs.docker.com/userguide/dockervolumes/) could be used for that. The image uses exactly the file system structure defined by the [ApacheDS documentation](https://directory.apache.org/apacheds/advanced-ug/2.2.1-debian-instance-layout.html).
The folder */var/lib/apacheds* contains the runtime data and thus has been defined as a volume. The image uses exactly the file system structure defined by the [ApacheDS documentation](https://directory.apache.org/apacheds/advanced-ug/2.2.1-debian-instance-layout.html).

The container can be started issuing the following command:

Expand Down
26 changes: 23 additions & 3 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/local/bin/dumb-init /bin/bash

# Environment variables:
# APACHEDS_VERSION
Expand All @@ -9,6 +9,7 @@
# APACHEDS_GROUP

APACHEDS_INSTANCE_DIRECTORY=${APACHEDS_DATA}/${APACHEDS_INSTANCE}
PIDFILE="${APACHEDS_INSTANCE_DIRECTORY}/run/apacheds-${APACHEDS_INSTANCE}.pid"

# When a fresh data folder is detected then bootstrap the instance configuration.
if [ ! -d ${APACHEDS_INSTANCE_DIRECTORY} ]; then
Expand All @@ -17,5 +18,24 @@ if [ ! -d ${APACHEDS_INSTANCE_DIRECTORY} ]; then
chown -v -R ${APACHEDS_USER}:${APACHEDS_GROUP} ${APACHEDS_INSTANCE_DIRECTORY}
fi

# Execute the server in console mode and not as a daemon.
/opt/apacheds-${APACHEDS_VERSION}/bin/apacheds console ${APACHEDS_INSTANCE}
cleanup(){
if [ -e "${PIDFILE}" ];
then
echo "Cleaning up ${PIDFILE}"
rm "${PIDFILE}"
fi
}

trap cleanup EXIT
cleanup

/opt/apacheds-${APACHEDS_VERSION}/bin/apacheds start ${APACHEDS_INSTANCE}
sleep 2 # Wait on new pid

shutdown(){
echo "Shutting down..."
/opt/apacheds-${APACHEDS_VERSION}/bin/apacheds stop ${APACHEDS_INSTANCE}
}

trap shutdown INT TERM
tail -n 0 --pid=$(cat $PIDFILE) -f ${APACHEDS_INSTANCE_DIRECTORY}/log/apacheds.log