Skip to content

Conversation

tianon
Copy link
Member

@tianon tianon commented Aug 2, 2016

This is intended as something to think about and discuss first, which is why I've not run update.sh yet. 😄

The intended use case is to allow for these pre-provided environment variables which are currently hard-coded and can only be changed by modifying this envvars file to be easily user-specifiable via -e on the docker run command line.

Before:

unset HOME

if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
    SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
    SUFFIX=
fi

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX

export LANG=C

export LANG

After:

unset HOME

if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
    SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
    SUFFIX=
fi

: ${APACHE_RUN_USER:=www-data}
export APACHE_RUN_USER
: ${APACHE_RUN_GROUP:=www-data}
export APACHE_RUN_GROUP
: ${APACHE_PID_FILE:=/var/run/apache2/apache2$SUFFIX.pid}
export APACHE_PID_FILE
: ${APACHE_RUN_DIR:=/var/run/apache2$SUFFIX}
export APACHE_RUN_DIR
: ${APACHE_LOCK_DIR:=/var/lock/apache2$SUFFIX}
export APACHE_LOCK_DIR
: ${APACHE_LOG_DIR:=/var/log/apache2$SUFFIX}
export APACHE_LOG_DIR

: ${LANG:=C}
export LANG

export LANG

(minus comments)

Fixes #14

…A:=B}" such that we can override them at runtime easily

Before:

```sh
unset HOME

if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
	SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
	SUFFIX=
fi

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
export APACHE_PID_FILE=/var/run/apache2/apache2$SUFFIX.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX

export LANG=C

export LANG
```

After:

```sh
unset HOME

if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
	SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
	SUFFIX=
fi

: ${APACHE_RUN_USER:=www-data}
export APACHE_RUN_USER
: ${APACHE_RUN_GROUP:=www-data}
export APACHE_RUN_GROUP
: ${APACHE_PID_FILE:=/var/run/apache2/apache2$SUFFIX.pid}
export APACHE_PID_FILE
: ${APACHE_RUN_DIR:=/var/run/apache2$SUFFIX}
export APACHE_RUN_DIR
: ${APACHE_LOCK_DIR:=/var/lock/apache2$SUFFIX}
export APACHE_LOCK_DIR
: ${APACHE_LOG_DIR:=/var/log/apache2$SUFFIX}
export APACHE_LOG_DIR

: ${LANG:=C}
export LANG

export LANG
```

(minus comments)
@tianon
Copy link
Member Author

tianon commented Aug 2, 2016

The main thing I see this breaking is folks who are using sed on this file themselves, but I did do a search of GitHub for Dockerfiles mentioning /etc/apache2/envvars and came up pretty near empty as far as anyone actually doing that in a major way. (Which isn't to say nobody is, but it does mean it's probably not a normal practice -- most folks I saw were just replacing the file outright or sourcing it for other reasons.)

@tianon
Copy link
Member Author

tianon commented Aug 2, 2016

This has fun implications for issues like #14 too. 😄 (To be clear, by "fun", I mean "likely fixes the issue".)

@yosifkit
Copy link
Member

yosifkit commented Aug 2, 2016

👍, though I kind of wish something like document root was in there too, so we could solve some other issues.

@tianon
Copy link
Member Author

tianon commented Aug 8, 2016

Yeah, I think that's something we could consider adding pretty easily as a "next step" following this, if we decide it makes sense. Should be pretty easy to implement. 👍

(I've just pushed a commit applying update.sh changes.)

@yosifkit
Copy link
Member

yosifkit commented Aug 8, 2016

LGTM

@yosifkit yosifkit merged commit 893b4f7 into docker-library:master Aug 8, 2016
@yosifkit yosifkit deleted the override-envvars branch August 8, 2016 19:03
@Vampouille
Copy link

This has fun implications for issues like #14 too. (To be clear, by "fun", I mean "likely fixes the issue".)

@tianon, I think #14 is about changing UID at runtime by environment variables. With this PR, we can only change apache user at build time and we need to extend image with creation of such user.

So can you reopen #14 ?

@tianon
Copy link
Member Author

tianon commented Aug 9, 2016

@Vampouille it used to be build-time only, but this PR makes it possible to set variables like APACHE_RUN_USER at runtime -- the current issue with using it is that it hasn't made it over to https://github.com/docker-library/official-images yet

tianon added a commit to infosiftr/stackbrew that referenced this pull request Aug 9, 2016
- `elasticsearch`: 5.0.0-alpha5 (docker-library/elasticsearch#113)
- `php`: `/etc/apache2/envvars` tweaks (docker-library/php#282), `--enable-ftp` (docker-library/php#287)
- `piwik`: swap from merge commit to commit with substance (direct output of `generate-stackbrew-library.sh`)
- `python`: templates (docker-library/python#139), fix `import dbm` (docker-library/python#140)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants