Skip to content

Commit 893b4f7

Browse files
authored
Merge pull request docker-library#282 from infosiftr/override-envvars
Convert explicit "export A=B" lines of Apache's envvars file into "${A:=B}" such that we can override them at runtime easily
2 parents 2cc40ce + aea63e3 commit 893b4f7

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

5.5/apache/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,17 @@ RUN apt-get update && apt-get install -y apache2-bin apache2.2-common --no-insta
3535
ENV APACHE_CONFDIR /etc/apache2
3636
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
3737

38-
# setup directories and permissions
3938
RUN set -ex \
39+
\
40+
# generically convert lines like
41+
# export APACHE_RUN_USER=www-data
42+
# into
43+
# : ${APACHE_RUN_USER:=www-data}
44+
# export APACHE_RUN_USER
45+
# so that they can be overridden at runtime ("-e APACHE_RUN_USER=...")
46+
&& sed -r 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS" \
47+
\
48+
# setup directories and permissions
4049
&& . "$APACHE_ENVVARS" \
4150
&& for dir in \
4251
"$APACHE_LOCK_DIR" \

5.6/apache/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,17 @@ RUN apt-get update && apt-get install -y apache2-bin apache2.2-common --no-insta
3535
ENV APACHE_CONFDIR /etc/apache2
3636
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
3737

38-
# setup directories and permissions
3938
RUN set -ex \
39+
\
40+
# generically convert lines like
41+
# export APACHE_RUN_USER=www-data
42+
# into
43+
# : ${APACHE_RUN_USER:=www-data}
44+
# export APACHE_RUN_USER
45+
# so that they can be overridden at runtime ("-e APACHE_RUN_USER=...")
46+
&& sed -r 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS" \
47+
\
48+
# setup directories and permissions
4049
&& . "$APACHE_ENVVARS" \
4150
&& for dir in \
4251
"$APACHE_LOCK_DIR" \

7.0/apache/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,17 @@ RUN apt-get update && apt-get install -y apache2-bin apache2.2-common --no-insta
3535
ENV APACHE_CONFDIR /etc/apache2
3636
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
3737

38-
# setup directories and permissions
3938
RUN set -ex \
39+
\
40+
# generically convert lines like
41+
# export APACHE_RUN_USER=www-data
42+
# into
43+
# : ${APACHE_RUN_USER:=www-data}
44+
# export APACHE_RUN_USER
45+
# so that they can be overridden at runtime ("-e APACHE_RUN_USER=...")
46+
&& sed -r 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS" \
47+
\
48+
# setup directories and permissions
4049
&& . "$APACHE_ENVVARS" \
4150
&& for dir in \
4251
"$APACHE_LOCK_DIR" \

apache-Dockerfile-block-1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@ RUN apt-get update && apt-get install -y apache2-bin apache2.2-common --no-insta
33
ENV APACHE_CONFDIR /etc/apache2
44
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
55

6-
# setup directories and permissions
76
RUN set -ex \
7+
\
8+
# generically convert lines like
9+
# export APACHE_RUN_USER=www-data
10+
# into
11+
# : ${APACHE_RUN_USER:=www-data}
12+
# export APACHE_RUN_USER
13+
# so that they can be overridden at runtime ("-e APACHE_RUN_USER=...")
14+
&& sed -r 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS" \
15+
\
16+
# setup directories and permissions
817
&& . "$APACHE_ENVVARS" \
918
&& for dir in \
1019
"$APACHE_LOCK_DIR" \

0 commit comments

Comments
 (0)