+# Dockerfile for Citadel
+
FROM bitnami/minideb:latest
VOLUME /citadel-data
# Install prerequisites
RUN install_packages make build-essential zlib1g-dev libldap2-dev libssl-dev gettext libical-dev libexpat1-dev curl libcurl4-openssl-dev git autoconf automake netbase libreadline-dev
-# Download and build Citadel
-WORKDIR /tmp/ctdl_build
-RUN sh -c 'git clone git://git.citadel.org/appl/gitroot/citadel.git'
-RUN sh -c 'cd /tmp/ctdl_build/citadel/libcitadel && ./bootstrap && ./configure --prefix=/usr && make && make install'
-RUN sh -c 'cd /tmp/ctdl_build/citadel/citadel && ./bootstrap && ./configure && make && make install'
-RUN sh -c 'cd /tmp/ctdl_build/citadel/webcit && ./bootstrap && ./configure && make && make install'
-RUN sh -c 'cd /tmp/ctdl_build/citadel/textclient && ./bootstrap && ./configure --prefix=/usr && make && make install'
-RUN sh -c 'cd /tmp && rm -vfr /tmp/ctdl_build'
-RUN sh -c 'rm -vrf /usr/local/citadel/data /usr/local/citadel/files /usr/local/citadel/keys /usr/local/webcit/keys'
+# Deploy "ctdlvisor", a small supervisor program which runs inside the container to wrangle the various services
+ADD ctdlvisor.c /tmp
-# ctdlvisor is a supervisor process that handles all of the components
-ADD ctdlvisor.c /tmp/ctdl_build
-RUN sh -c 'cd /tmp/ctdl_build && cc ctdlvisor.c -o /usr/local/bin/ctdlvisor'
+# Download and build Citadel
+RUN sh -c 'mkdir /tmp/ctdl_build && \
+ cd /tmp/ctdl_build && \
+ git clone git://git.citadel.org/appl/gitroot/citadel.git && \
+ cd /tmp/ctdl_build/citadel/libcitadel && \
+ ./bootstrap && \
+ ./configure --prefix=/usr && \
+ make && \
+ make install && \
+ cd /tmp/ctdl_build/citadel/citadel && \
+ ./bootstrap && \
+ ./configure && \
+ make && \
+ make install && \
+ cd /tmp/ctdl_build/citadel/webcit && \
+ ./bootstrap && \
+ ./configure && \
+ make && \
+ make install && \
+ cd /tmp/ctdl_build/citadel/textclient && \
+ ./bootstrap && \
+ ./configure --prefix=/usr --ctdldir=/citadel_data && \
+ make && make install && \
+ cd /tmp && \
+ cc ctdlvisor.c -o /usr/local/bin/ctdlvisor && \
+ rm -vf /tmp/ctdlvisor.c && \
+ cd /tmp && \
+ rm -vfr /tmp/ctdl_build && \
+ rm -vrf /usr/local/citadel/data /usr/local/citadel/files /usr/local/citadel/keys /usr/local/webcit/keys'
# Ports
EXPOSE 25 80 110 119 143 443 465 504 563 587 993 995 2020 5222
-# We don't need the workdir anymore
-RUN rm -fr /tmp/ctdl_build
-
# Let's go!
ENTRYPOINT ["/usr/local/bin/ctdlvisor"]
}
-void install_client_link(void) { // FIXME this is all furkokt and needs to be rethought now that it's docker and not appimage
-
- FILE *fp;
- char path_to_link[PATH_MAX];
- snprintf(path_to_link, sizeof path_to_link, CTDL_DIR "citadel");
- fp = fopen(path_to_link, "w");
- if (!fp) {
- fprintf(stderr, "%s\n", strerror(errno));
- return;
- }
-
- fprintf(fp, "#!/bin/bash\n"
- "export APPDIR=%s\n"
- "export LD_LIBRARY_PATH=${APPDIR}/usr/bin:$LD_LIBRARY_PATH\n"
- "export PATH=${APPDIR}/usr/bin:$PATH\n"
- "exec citadel\n"
- ,
- getenv("APPDIR")
- );
-
- fchmod(fileno(fp), 0755);
- fclose(fp);
-}
-
-
int main(int argc, char **argv) {
int a;
int migrate_mode = 0;
webcit_pid = start_webcit(); // start WebCit HTTP
webcits_pid = start_webcits(); // start WebCit HTTPS
- install_client_link();
-
main_loop();
}
# The container expects a persistent volume called "citadel-data" in which it will keep everything.
# The remainder of the container is ephermal and can be deleted at any time.
-# If you want to keep your Citadel data in a specific directory on the host,
-# set CTDL_VOL to "bind" and CTDL_DIR to the full pathname of that directory.
-# This is what you want if you are switching from Easy Install to Docker.
-#
-#CTDL_VOL=bind
-#CTDL_DIR=/usr/local/citadel
-# If you want to keep your Citadel data in a Docker volume,
-# set CTDL_VOL to "volume" and CTDL_DIR to the name of the volume.
-#
-CTDL_VOL=volume
-CTDL_DIR=citadel-data
+# Parse the command line arguments
+
+migrate_mode=false
+database_cleanup_mode=false
+volume_mode=false
+bind_mode=false
+
+while getopts ":mdv:h:" o
+do
+ case "${o}" in
+ m)
+ echo "migrate mode"
+ migrate_mode=true
+ ;;
+ d)
+ echo "database cleanup mode";
+ database_cleanup_mode=true
+ ;;
+ v)
+ volume_mode=true
+ CTDL_DIR=${OPTARG}
+ ;;
+ h)
+ bind_mode=true
+ CTDL_DIR=${OPTARG}
+ ;;
+ *)
+ echo "$0: usage: $0 [-v volume_name] [-h home_directory] [-m] [-v] container_image_name [other parameters]"
+ exit 1
+ ;;
+ esac
+done
+shift $((OPTIND-1))
+
+if ( ${volume_mode} && ${bind_mode} ) ; then
+ echo "$0: -v and -h cannot both be specified."
+ exit 2
+fi
+
+if ${volume_mode} ; then
+ CTDL_VOL=volume
+elif ${bind_mode} ; then
+ CTDL_VOL=bind
+else
+ volume_mode=true
+ CTDL_VOL=volume
+ CTDL_DIR=citadel-data
+fi
+
+if ( ${migrate_mode} && ${database_cleanup_mode} ) ; then
+ echo "$0: -m and -d cannot both be specified."
+ exit 3
+fi
docker version >/dev/null 2>&1 || {
echo Docker engine is not installed on this host.