-
Notifications
You must be signed in to change notification settings - Fork 11
/
Dockerfile-captain
67 lines (54 loc) · 3.03 KB
/
Dockerfile-captain
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# this is the dockerfile for use when deploying with CapRover:
# https://github.com/caprover/caprover/
# this is suitable for deploying to an ubuntu-based docker container running apache2
# compilation of the astro-api bits is based on the docker file at the top level of https://github.com/FrankThomasTveter/astro-api
# but instead of using 'httpd' as a starting point for the Docker container (with apache2 pre-installed), I am
# using 'ubuntu' and then just installing apache2 within that... seems to lead to a much more complete
# installation of apache2 on ubuntu with everything corresponding more closely to what is expected from various help guides out there
# e.g. https://www.digitalocean.com/community/tutorials/how-to-configure-the-apache-web-server-on-an-ubuntu-or-debian-vps
# and https://help.ubuntu.com/lts/serverguide/httpd.html
# this approach (start with ubuntu and add apache2) is based on the dockerfile at: https://stackoverflow.com/a/44377561/4070848
# start with ubuntu and add apache2 below
FROM ubuntu:22.04
# now install tini (an alternative to dumb-init)... good practice to have a dumb-init process as first process in container with PID=1
# see: https://github.com/Yelp/dumb-init
ENV TINI_VERSION v0.17.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
# install apache2
RUN apt-get update && \
apt-get -y install apache2
# Install dependencies required for astro-api compilation
RUN apt-get -y update && \
apt-get -y install tcsh && \
apt-get -y install make && \
apt-get -y install gfortran && \
apt-get -y install devscripts && \
apt-get -y install libapache2-mod-perl2
# set appropriate work dir for CapRover
# see https://caprover.com/docs/captain-definition-file.html
WORKDIR /usr/src/app
# copy files from deployment location into container filesystem
COPY . /usr/src/app
# compile astro-api
RUN cd astro/src; make && \
cd astro/perl; perl Makefile.PL; make clean; perl Makefile.PL; make && \
make install
# copy compiled files to apache2 folders appropriate to ubuntu installation
# note that we copy rather than move because that preserves the previous astro-api compilation layer
# so that it does not need to be re-run on the next deploy
RUN cp -a /usr/src/app/html/astro /var/www/html && \
cp -a /usr/src/app/cgi-bin/astro /usr/lib/cgi-bin
# expose port 80 to make this accessible to others
EXPOSE 80
# enable cgi so that perl scripts in the cgi-bin folder can be accessed and executed
# this involves enabling the cgi module (https://askubuntu.com/a/54259/760204) and
# appending some custom config lines to the default apache2 config file (based on
# some lines in the docker file from the astro-api repo)
RUN a2enmod cgi && \
cat /usr/src/app/captain-apache2.conf >> /etc/apache2/apache2.conf
# set tini (like dumb-init) as the entrypoint to make it PID=1 (see note above)
ENTRYPOINT ["/tini", "--"]
# and finally, set the main show going...
# start service in foreground as per https://stackoverflow.com/a/44377561/4070848
CMD apachectl -D FOREGROUND