Skip to content

Commit 6dde0f5

Browse files
author
Julien Neuhart
committed
fixing apache install
1 parent f1bce1b commit 6dde0f5

File tree

8 files changed

+251
-85
lines changed

8 files changed

+251
-85
lines changed

Dockerfile.10

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ RUN SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.
2828
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
2929
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
3030

31+
# |--------------------------------------------------------------------------
32+
# | User
33+
# |--------------------------------------------------------------------------
34+
# |
35+
# | Define a default user with sudo rights.
36+
# |
37+
38+
RUN useradd -ms /bin/bash docker && adduser docker sudo
39+
# Users in the sudoers group can sudo as root without password.
40+
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
41+
3142

3243

3344

@@ -56,17 +67,6 @@ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&\
5667
apt-get update &&\
5768
apt-get install -y --no-install-recommends yarn
5869

59-
# |--------------------------------------------------------------------------
60-
# | User
61-
# |--------------------------------------------------------------------------
62-
# |
63-
# | Define a default user with sudo rights.
64-
# |
65-
66-
RUN useradd -ms /bin/bash docker && adduser docker sudo
67-
# Users in the sudoers group can sudo as root without password.
68-
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
69-
7070
# |--------------------------------------------------------------------------
7171
# | PATH updating
7272
# |--------------------------------------------------------------------------

Dockerfile.10-apache

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ RUN SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.
2828
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
2929
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
3030

31+
# |--------------------------------------------------------------------------
32+
# | User
33+
# |--------------------------------------------------------------------------
34+
# |
35+
# | Define a default user with sudo rights.
36+
# |
37+
38+
RUN useradd -ms /bin/bash docker && adduser docker sudo
39+
# Users in the sudoers group can sudo as root without password.
40+
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
41+
3142

3243

3344
# |--------------------------------------------------------------------------
@@ -36,8 +47,37 @@ RUN SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.
3647
# |
3748
# | Installs Apache.
3849
# |
39-
RUN apt-get update &&\
40-
apt-get install -y --no-install-recommends apache2
50+
51+
# generically convert lines like
52+
# export APACHE_RUN_USER=www-data
53+
# into
54+
# : ${APACHE_RUN_USER:=www-data}
55+
# export APACHE_RUN_USER
56+
# so that they can be overridden at runtime ("-e APACHE_RUN_USER=...")
57+
&& sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS" \
58+
\
59+
# setup directories and permissions
60+
&& . "$APACHE_ENVVARS" \
61+
&& for dir in \
62+
"$APACHE_LOCK_DIR" \
63+
"$APACHE_RUN_DIR" \
64+
"$APACHE_LOG_DIR" \
65+
/var/www/html \
66+
; do \
67+
rm -rvf "$dir" \
68+
&& mkdir -p "$dir" \
69+
&& chown -R "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; \
70+
done
71+
72+
# Apache + PHP requires preforking Apache for best results
73+
RUN a2dismod mpm_event && a2enmod mpm_prefork
74+
75+
# logs should go to stdout / stderr
76+
RUN set -ex \
77+
&& . "$APACHE_ENVVARS" \
78+
&& ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log" \
79+
&& ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log" \
80+
&& ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log"
4181

4282
ENV APACHE_DOCUMENT_ROOT /
4383

@@ -79,17 +119,6 @@ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&\
79119
apt-get update &&\
80120
apt-get install -y --no-install-recommends yarn
81121

82-
# |--------------------------------------------------------------------------
83-
# | User
84-
# |--------------------------------------------------------------------------
85-
# |
86-
# | Define a default user with sudo rights.
87-
# |
88-
89-
RUN useradd -ms /bin/bash docker && adduser docker sudo
90-
# Users in the sudoers group can sudo as root without password.
91-
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
92-
93122
# |--------------------------------------------------------------------------
94123
# | PATH updating
95124
# |--------------------------------------------------------------------------
@@ -160,6 +189,8 @@ COPY utils/apache-expose-envvars.sh /usr/local/bin/apache-expose-envvars.sh
160189
RUN echo "ServerName localhost" > /etc/apache2/conf-available/servername.conf
161190
RUN a2enconf servername
162191

192+
EXPOSE 80
193+
163194
# |--------------------------------------------------------------------------
164195
# | Apache user
165196
# |--------------------------------------------------------------------------
@@ -172,6 +203,7 @@ RUN a2enconf servername
172203
ENV APACHE_RUN_USER=docker \
173204
APACHE_RUN_GROUP=docker
174205

206+
COPY apache2-foreground /usr/local/bin/
175207
CMD ["apache2-foreground"]
176208

177209

Dockerfile.6

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ RUN SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.
2828
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
2929
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
3030

31+
# |--------------------------------------------------------------------------
32+
# | User
33+
# |--------------------------------------------------------------------------
34+
# |
35+
# | Define a default user with sudo rights.
36+
# |
37+
38+
RUN useradd -ms /bin/bash docker && adduser docker sudo
39+
# Users in the sudoers group can sudo as root without password.
40+
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
41+
3142

3243

3344

@@ -56,17 +67,6 @@ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&\
5667
apt-get update &&\
5768
apt-get install -y --no-install-recommends yarn
5869

59-
# |--------------------------------------------------------------------------
60-
# | User
61-
# |--------------------------------------------------------------------------
62-
# |
63-
# | Define a default user with sudo rights.
64-
# |
65-
66-
RUN useradd -ms /bin/bash docker && adduser docker sudo
67-
# Users in the sudoers group can sudo as root without password.
68-
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
69-
7070
# |--------------------------------------------------------------------------
7171
# | PATH updating
7272
# |--------------------------------------------------------------------------

Dockerfile.6-apache

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ RUN SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.
2828
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
2929
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
3030

31+
# |--------------------------------------------------------------------------
32+
# | User
33+
# |--------------------------------------------------------------------------
34+
# |
35+
# | Define a default user with sudo rights.
36+
# |
37+
38+
RUN useradd -ms /bin/bash docker && adduser docker sudo
39+
# Users in the sudoers group can sudo as root without password.
40+
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
41+
3142

3243

3344
# |--------------------------------------------------------------------------
@@ -36,8 +47,37 @@ RUN SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.
3647
# |
3748
# | Installs Apache.
3849
# |
39-
RUN apt-get update &&\
40-
apt-get install -y --no-install-recommends apache2
50+
51+
# generically convert lines like
52+
# export APACHE_RUN_USER=www-data
53+
# into
54+
# : ${APACHE_RUN_USER:=www-data}
55+
# export APACHE_RUN_USER
56+
# so that they can be overridden at runtime ("-e APACHE_RUN_USER=...")
57+
&& sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS" \
58+
\
59+
# setup directories and permissions
60+
&& . "$APACHE_ENVVARS" \
61+
&& for dir in \
62+
"$APACHE_LOCK_DIR" \
63+
"$APACHE_RUN_DIR" \
64+
"$APACHE_LOG_DIR" \
65+
/var/www/html \
66+
; do \
67+
rm -rvf "$dir" \
68+
&& mkdir -p "$dir" \
69+
&& chown -R "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; \
70+
done
71+
72+
# Apache + PHP requires preforking Apache for best results
73+
RUN a2dismod mpm_event && a2enmod mpm_prefork
74+
75+
# logs should go to stdout / stderr
76+
RUN set -ex \
77+
&& . "$APACHE_ENVVARS" \
78+
&& ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log" \
79+
&& ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log" \
80+
&& ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log"
4181

4282
ENV APACHE_DOCUMENT_ROOT /
4383

@@ -79,17 +119,6 @@ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&\
79119
apt-get update &&\
80120
apt-get install -y --no-install-recommends yarn
81121

82-
# |--------------------------------------------------------------------------
83-
# | User
84-
# |--------------------------------------------------------------------------
85-
# |
86-
# | Define a default user with sudo rights.
87-
# |
88-
89-
RUN useradd -ms /bin/bash docker && adduser docker sudo
90-
# Users in the sudoers group can sudo as root without password.
91-
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
92-
93122
# |--------------------------------------------------------------------------
94123
# | PATH updating
95124
# |--------------------------------------------------------------------------
@@ -160,6 +189,8 @@ COPY utils/apache-expose-envvars.sh /usr/local/bin/apache-expose-envvars.sh
160189
RUN echo "ServerName localhost" > /etc/apache2/conf-available/servername.conf
161190
RUN a2enconf servername
162191

192+
EXPOSE 80
193+
163194
# |--------------------------------------------------------------------------
164195
# | Apache user
165196
# |--------------------------------------------------------------------------
@@ -172,6 +203,7 @@ RUN a2enconf servername
172203
ENV APACHE_RUN_USER=docker \
173204
APACHE_RUN_GROUP=docker
174205

206+
COPY apache2-foreground /usr/local/bin/
175207
CMD ["apache2-foreground"]
176208

177209

Dockerfile.8

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ RUN SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.
2828
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
2929
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
3030

31+
# |--------------------------------------------------------------------------
32+
# | User
33+
# |--------------------------------------------------------------------------
34+
# |
35+
# | Define a default user with sudo rights.
36+
# |
37+
38+
RUN useradd -ms /bin/bash docker && adduser docker sudo
39+
# Users in the sudoers group can sudo as root without password.
40+
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
41+
3142

3243

3344

@@ -56,17 +67,6 @@ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&\
5667
apt-get update &&\
5768
apt-get install -y --no-install-recommends yarn
5869

59-
# |--------------------------------------------------------------------------
60-
# | User
61-
# |--------------------------------------------------------------------------
62-
# |
63-
# | Define a default user with sudo rights.
64-
# |
65-
66-
RUN useradd -ms /bin/bash docker && adduser docker sudo
67-
# Users in the sudoers group can sudo as root without password.
68-
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
69-
7070
# |--------------------------------------------------------------------------
7171
# | PATH updating
7272
# |--------------------------------------------------------------------------

Dockerfile.8-apache

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ RUN SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.
2828
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
2929
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
3030

31+
# |--------------------------------------------------------------------------
32+
# | User
33+
# |--------------------------------------------------------------------------
34+
# |
35+
# | Define a default user with sudo rights.
36+
# |
37+
38+
RUN useradd -ms /bin/bash docker && adduser docker sudo
39+
# Users in the sudoers group can sudo as root without password.
40+
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
41+
3142

3243

3344
# |--------------------------------------------------------------------------
@@ -36,8 +47,37 @@ RUN SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.
3647
# |
3748
# | Installs Apache.
3849
# |
39-
RUN apt-get update &&\
40-
apt-get install -y --no-install-recommends apache2
50+
51+
# generically convert lines like
52+
# export APACHE_RUN_USER=www-data
53+
# into
54+
# : ${APACHE_RUN_USER:=www-data}
55+
# export APACHE_RUN_USER
56+
# so that they can be overridden at runtime ("-e APACHE_RUN_USER=...")
57+
&& sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS" \
58+
\
59+
# setup directories and permissions
60+
&& . "$APACHE_ENVVARS" \
61+
&& for dir in \
62+
"$APACHE_LOCK_DIR" \
63+
"$APACHE_RUN_DIR" \
64+
"$APACHE_LOG_DIR" \
65+
/var/www/html \
66+
; do \
67+
rm -rvf "$dir" \
68+
&& mkdir -p "$dir" \
69+
&& chown -R "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; \
70+
done
71+
72+
# Apache + PHP requires preforking Apache for best results
73+
RUN a2dismod mpm_event && a2enmod mpm_prefork
74+
75+
# logs should go to stdout / stderr
76+
RUN set -ex \
77+
&& . "$APACHE_ENVVARS" \
78+
&& ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log" \
79+
&& ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log" \
80+
&& ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log"
4181

4282
ENV APACHE_DOCUMENT_ROOT /
4383

@@ -79,17 +119,6 @@ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&\
79119
apt-get update &&\
80120
apt-get install -y --no-install-recommends yarn
81121

82-
# |--------------------------------------------------------------------------
83-
# | User
84-
# |--------------------------------------------------------------------------
85-
# |
86-
# | Define a default user with sudo rights.
87-
# |
88-
89-
RUN useradd -ms /bin/bash docker && adduser docker sudo
90-
# Users in the sudoers group can sudo as root without password.
91-
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
92-
93122
# |--------------------------------------------------------------------------
94123
# | PATH updating
95124
# |--------------------------------------------------------------------------
@@ -160,6 +189,8 @@ COPY utils/apache-expose-envvars.sh /usr/local/bin/apache-expose-envvars.sh
160189
RUN echo "ServerName localhost" > /etc/apache2/conf-available/servername.conf
161190
RUN a2enconf servername
162191

192+
EXPOSE 80
193+
163194
# |--------------------------------------------------------------------------
164195
# | Apache user
165196
# |--------------------------------------------------------------------------
@@ -172,6 +203,7 @@ RUN a2enconf servername
172203
ENV APACHE_RUN_USER=docker \
173204
APACHE_RUN_GROUP=docker
174205

206+
COPY apache2-foreground /usr/local/bin/
175207
CMD ["apache2-foreground"]
176208

177209

0 commit comments

Comments
 (0)