Build from the published sources, not from git
[citadel-docker.git] / Dockerfile
1 # Dockerfile for Citadel
2 #
3 # Copyright (c) 2019-2023 by the citadel.org team
4 #
5 # This program is open source software.  Use, duplication, or disclosure
6 # is subject to the terms of the GNU General Public License, version 3.
7
8 # This script implements a two stage build.  In the first stage we load in a full set of
9 # development tools and build all of the components, including a version of Berkeley DB newer than
10 # the one supplied in the repo.  Everything in /usr/local is copied into the second stage, which
11 # is built with only runtime libraries to keep the image small.
12
13 ####################################################################################################
14
15 # Debian Slim has all of the architectures we build on (amd64, i386, arm32)
16 # The first stage build will bring in all of our development tools.
17 FROM debian:bullseye-slim AS build-stage
18
19 # All long term persistent data goes here.  Any volume driver may be used.
20 VOLUME /citadel-data
21
22 # Install prerequisites
23 RUN apt -y update
24 RUN apt -y install gcc bison make zlib1g-dev libldap2-dev libssl-dev gettext libical-dev libexpat1-dev curl libcurl4-openssl-dev git autoconf automake netbase libreadline-dev
25
26 # Build our own local copy of Berkeley DB, because the one included with the system libs is too old.
27 # We will install it to /usr/local and carry it over to the second stage build.
28 # build and install Berkeley DB
29 RUN sh -c 'mkdir /tmp/db_build'
30 RUN sh -c 'cd /tmp/db_build && curl -k https://easyinstall.citadel.org/db-18.1.40.tar.gz | tar xvzf -'
31 RUN sh -c '\
32         cd /tmp/db_build/db-18.1.40/build_unix && \
33         ../dist/configure --prefix=/usr/local \
34                 --with-cryptography=no --disable-hash --disable-heap --disable-queue \
35                 --disable-replication --disable-statistics \
36                 --with-uniquename=_ctdl \
37                 --enable-static --disable-shared \
38                 --disable-compat185 --disable-cxx --disable-debug \
39                 --disable-dump185 --disable-java --disable-tcl --disable-test --without-rpm'
40 RUN sh -c 'cd /tmp/db_build/db-18.1.40/build_unix && make -j`cat /proc/cpuinfo  | grep processor | wc -l`'
41 RUN sh -c 'cd /tmp/db_build/db-18.1.40/build_unix && make install_lib'
42 RUN sh -c 'cd /tmp/db_build/db-18.1.40/build_unix && make install_include'
43 RUN sh -c 'cd /tmp/db_build/db-18.1.40/build_unix && make install_utilities'
44 RUN sh -c 'rm -fr /tmp/db_build'
45
46 # Create our build directory
47 RUN mkdir /tmp/ctdl_build
48
49 # Deploy "ctdlvisor", a small supervisor program which runs inside the container to wrangle the various services
50 ADD ctdlvisor.c /tmp
51 RUN sh -c '\
52         cd /tmp && \
53         cc ctdlvisor.c -o /usr/local/bin/ctdlvisor && \
54         rm -vf /tmp/ctdlvisor.c'
55
56 # Download the latest Citadel code
57 RUN curl https://easyinstall.citadel.org/libcitadel-easyinstall.tar.gz | tar xvzf -
58 RUN curl https://easyinstall.citadel.org/citadel-easyinstall.tar.gz | tar xvzf -
59 RUN curl https://easyinstall.citadel.org/webcit-easyinstall.tar.gz | tar xvzf -
60 RUN curl https://easyinstall.citadel.org/textclient-easyinstall.tar.gz | tar xvzf -
61
62 # Build libcitadel
63 RUN sh -c '\
64         cd libcitadel && \
65         ./configure --prefix=/usr/local && \
66         make && \
67         make install'
68
69 # Build the Citadel Server
70 RUN sh -c '\
71         export CFLAGS=-I/usr/local/include && \
72         export LDFLAGS=-L/usr/local/lib && \
73         cd citadel && \
74         ./configure && \
75         make && \
76         make install'
77
78 # Build the WebCit front end
79 RUN sh -c '\
80         export CFLAGS=-I/usr/local/include && \
81         export LDFLAGS=-L/usr/local/lib && \
82         cd webcit && \
83         ./configure && \
84         make && \
85         make install'
86
87 # Build the text mode client
88 RUN sh -c '\
89         export CFLAGS=-I/usr/local/include && \
90         export LDFLAGS=-L/usr/local/lib && \
91         cd textclient && \
92         ./configure --prefix=/usr/local --ctdldir=/citadel_data && \
93         make && \
94         cp citadel /usr/local/bin && \
95         cp citadel.rc /usr/local/etc && \
96         rm -vrf /usr/local/citadel/data /usr/local/citadel/files /usr/local/citadel/keys /usr/local/webcit/keys'
97
98 ####################################################################################################
99
100 # Second stage build only needs runtime libraries.
101 FROM debian:bullseye-slim AS final-stage
102
103 # All long term persistent data goes here.  Any volume driver may be used.
104 VOLUME /citadel-data
105
106 # Install prerequisites
107 RUN apt -y update
108 RUN apt -y install zlib1g libical3 libexpat1 curl libcurl4 netbase libreadline8 libldap-2.4-2 libssl1.1
109
110 # Bring in Citadel and libraries
111 COPY --from=build-stage /usr/local/ /usr/local/
112 RUN ldconfig -v
113
114 # Ports
115 EXPOSE 25 80 110 119 143 443 465 504 563 587 993 995 5222
116
117 # Let's go!
118 ENTRYPOINT ["/usr/local/bin/ctdlvisor"]
119