-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
129 lines (106 loc) · 3.79 KB
/
Dockerfile
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
FROM ubuntu:20.04
LABEL MAINTAINER="Michael Priest <michael.priest@adelaide.edu.au>"
LABEL io.k8s.description="Platform for serving Drupal PHP apps in Shepherd" \
io.k8s.display-name="Shepherd Drupal" \
io.openshift.expose-services="8080:http" \
io.openshift.tags="builder,shepherd,drupal,php,apache" \
io.openshift.s2i.scripts-url="image:///usr/local/s2i"
ENV DEBIAN_FRONTEND noninteractive
# Configured timezone.
ENV TZ=Australia/Adelaide
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Ensure UTF-8.
ENV LANG en_AU.UTF-8
ENV LANGUAGE en_AU:en
ENV LC_ALL en_AU.UTF-8
# Upgrade all currently installed packages and install web server packages.
RUN apt-get update \
&& apt-get -y install locales \
&& sed -i -e 's/# en_AU.UTF-8 UTF-8/en_AU.UTF-8 UTF-8/' /etc/locale.gen \
&& locale-gen en_AU.UTF-8 \
&& apt-get -y dist-upgrade \
&& apt-get -y install \
apache2 \
bind9-host \
git \
gnupg2 \
iproute2 \
iputils-ping \
libapache2-mod-php \
libedit-dev \
mariadb-client \
php-apcu \
php-bcmath \
php-common \
php-curl \
php-gd \
php-ldap \
php-mbstring \
php-memcached \
php-mysql \
php-opcache \
php-redis \
php-soap \
php-xml \
php-zip \
rsync \
ssmtp \
telnet \
unzip \
wget \
&& apt-get -y autoremove && apt-get -y autoclean && apt-get clean && rm -rf /var/lib/apt/lists /tmp/* /var/tmp/*
# NewRelic is disabled by default.
ENV NEW_RELIC_ENABLED=false
# Install NewRelic agent https://docs.newrelic.com/docs/agents/php-agent/installation/php-agent-installation-ubuntu-debian
RUN echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \
wget -O- https://download.newrelic.com/548C16BF.gpg | apt-key add - && \
apt-get update && \
apt-get install -y newrelic-php5 && \
rm -f /etc/php/7.4/mods-available/newrelic.ini /etc/php/7.4/apache2/conf.d/20-newrelic.ini /etc/php/7.4/cli/conf.d/20-newrelic.ini
# Install Composer.
RUN wget -q https://getcomposer.org/installer -O - | php -- --install-dir=/usr/local/bin --filename=composer --version=1.10.22
RUN composer global require --no-interaction hirak/prestissimo
# Make bash the default shell.
RUN ln -sf /bin/bash /bin/sh
# Install PHP Local Security Checker
RUN wget -q -O /usr/local/bin/local-php-security-checker https://github.com/fabpot/local-php-security-checker/releases/download/v1.0.0/local-php-security-checker_1.0.0_linux_amd64 \
&& chmod +rx /usr/local/bin/local-php-security-checker
# Apache config.
COPY ./files/apache2.conf /etc/apache2/apache2.conf
# PHP config.
COPY ./files/php_custom.ini /etc/php/7.4/mods-available/php_custom.ini
COPY ./files/newrelic.ini /etc/php/7.4/apache2/conf.d/newrelic.ini
# Configure apache modules, php modules, logging.
RUN a2enmod rewrite \
&& a2dismod vhost_alias \
&& a2disconf other-vhosts-access-log \
&& a2dissite 000-default \
&& phpenmod -v ALL -s ALL php_custom
# Add /code /shared directories and ensure ownership by User 33 (www-data) and Group 0 (root).
RUN mkdir -p /code /shared
# Add s2i scripts.
COPY ./s2i/bin /usr/local/s2i
RUN chmod +x /usr/local/s2i/*
ENV PATH "$PATH:/usr/local/s2i:/code/bin"
# Web port.
EXPOSE 8080
# Set working directory.
WORKDIR /code
# Change all ownership to User 33 (www-data) and Group 0 (root).
RUN chown -R 33:0 /var/www \
&& chown -R 33:0 /run/lock \
&& chown -R 33:0 /var/run/apache2 \
&& chown -R 33:0 /var/log/apache2 \
&& chown -R 33:0 /code \
&& chown -R 33:0 /shared
RUN chmod -R g+rwX /var/www \
&& chmod -R g+rwX /run/lock \
&& chmod -R g+rwX /var/run/apache2 \
&& chmod -R g+rwX /var/log/apache2 \
&& chmod -R g+rwX /code \
&& chmod -R g+rwX /shared
# Change the homedir of www-data to be /code.
RUN usermod -d /code www-data
USER 33:0
# Start the web server.
CMD ["/usr/local/s2i/run"]