-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.template
98 lines (77 loc) · 2.92 KB
/
Dockerfile.template
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
FROM ubuntu:22.04
MAINTAINER Tin Benjamin Matuka <mail@tbmatuka.com>
# set up timezone
ARG TIMEZONE="UTC"
RUN ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && echo ${TIMEZONE} > /etc/timezone
# install deps, apache, php and php modules all in one run and clean up afterwards to reduce the snapshot size
RUN apt-get clean && \
apt-get -y update && \
apt-get install -y --force-yes \
locales \
curl \
software-properties-common \
git \
apt-transport-https \
sudo \
nvi \
nano \
iproute2 \
telnet \
dnsutils \
unzip \
rsync \
inetutils-ping && \
locale-gen en_US.UTF-8 && \
LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php && apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes \
apache2 \
ssmtp \
mysql-client \
imagemagick \
##php-packages## \
php-mail && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# copy remoteip.conf so that it can be enabled
COPY ./remoteip.conf /etc/apache2/conf-available/remoteip.conf
# enable missing modules
RUN phpenmod apcu && \
phpenmod apcu_bc && \
a2enmod rewrite headers ssl remoteip expires && \
a2enconf remoteip
# set php version as active
RUN update-alternatives --set php "/usr/bin/php##php-version##"
# set up php.ini
RUN cp "/etc/php/##php-version##/apache2/php.ini" "/etc/php/php.ini" ; \
mkdir /etc/php/conf.d; ln -s /etc/php/##php-version##/mods-available/* /etc/php/conf.d/ ; \
for phpenv in apache2 cli cgi; do \
mv "/etc/php/##php-version##/$phpenv/php.ini" "/etc/php/##php-version##/$phpenv/php.ini.dist" ; \
mv "/etc/php/##php-version##/$phpenv/conf.d" "/etc/php/##php-version##/$phpenv/conf.d.dist" ; \
ln -s /etc/php/php.ini "/etc/php/##php-version##/$phpenv/php.ini"; \
ln -s /etc/php/conf.d/ "/etc/php/##php-version##/$phpenv/conf.d"; \
done
# output apache logs to stdout
RUN ln -sf /proc/self/fd/1 /var/log/apache2/access.log && \
ln -sf /proc/self/fd/1 /var/log/apache2/error.log
# set up sendmail so that mail() can be used
RUN echo 'FromLineOverride=YES' >> /etc/ssmtp/ssmtp.conf
# add www-data to sudoers
COPY ./sudoers /etc/sudoers.d/www-data
# prepare www-data to be used as main user
RUN usermod -s /bin/bash -G staff www-data && \
mkdir -p /var/www /app && \
touch /var/www/.bash_profile && \
chown -R www-data. /var/www /app
# configure Apache
COPY ./vhost.conf /etc/apache2/sites-available/000-default.conf
COPY ./trusted-proxies.lst /etc/apache2/trusted-proxies.lst
# set up apache command
COPY ./apache2-foreground.sh /usr/local/sbin/apache2-foreground.sh
# prepare entrypoint and default command
COPY ./entrypoint.sh /usr/local/bin/
##fixes##
WORKDIR /app/
USER www-data
EXPOSE 80
HEALTHCHECK CMD curl --head http://localhost/ || exit 1
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD []