forked from FrankThomasTveter/astro-api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile-captain
63 lines (53 loc) · 2.69 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
# 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
# https://hub.docker.com/_/ubuntu
FROM ubuntu:24.04
# install apache2
RUN apt-get update \
&& apt-get install -y apache2 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# install dependencies required for astro-api compilation
RUN apt-get update \
&& apt-get install -y \
tcsh \
make \
gfortran \
devscripts \
libapache2-mod-perl2 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 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
# and finally, set the main show going...
# start service in foreground as per https://stackoverflow.com/a/44377561/4070848
ENTRYPOINT [ "apachectl", "-D", "FOREGROUND" ]