Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ We provide the following base containers which can be used in downstream project
## Features

- At every start, the php containers will recreate the symfony cache dir. </br>
- You can supply the environment variable APACHE_UID. It creates the user "openconext", and starts Apache with that the supplied uid.
- You can supply the environment variables APACHE_UID and APACHE_GID. It creates the user and group "openconext", and starts Apache with the supplied uid and gid.
This allows for strict permissions on mounted files.
You need to prefix the uid with a # like so:
You need to prefix the uid/gid with a # like so:
```
docker run -e APACHE_UID=#1337 ghcr.io/openconext/openconext-basecontainers/php72-apache2:latest
docker run -e APACHE_UID=#1337 -e APACHE_GID=#1337 ghcr.io/openconext/openconext-basecontainers/php72-apache2:latest
```
- You can supply the environment variable "HTTPD_CSP" which will set the CSP header on responses.
- You can supply the environment variable TZ to set the timezone on the php82 containers
Expand Down
20 changes: 12 additions & 8 deletions apache2-shibboleth/bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ if [[ -v APACHE_RUN_USER ]]; then
APACHE_UID=$APACHE_RUN_USER
fi
if [[ -v APACHE_RUN_GROUP ]]; then
APACHE_GUID=$APACHE_RUN_GROUP
APACHE_GID=$APACHE_RUN_GROUP
fi

if [[ ! -v APACHE_GID ]] && [[ -v APACHE_GUID ]]; then
APACHE_GID=$APACHE_GUID
fi

# Read the envars for Apache2
Expand All @@ -19,11 +23,11 @@ source /etc/apache2/envvars
if [[ -v APACHE_UID ]]; then
export APACHE_RUN_USER=$APACHE_UID
APACHE_UID_TO_CREATE=$(echo $APACHE_UID | sed 's/#//')
if [[ -v APACHE_GUID ]]; then
export APACHE_RUN_GROUP=$APACHE_GUID
APACHE_GUID_TO_CREATE=$(echo $APACHE_GUID | sed 's/#//')
[ $(getent group openconext) ] || groupadd -g $APACHE_GUID_TO_CREATE openconext
[ $(getent passwd openconext) ] || useradd -M -u $APACHE_UID_TO_CREATE -g $APACHE_GUID_TO_CREATE openconext
if [[ -v APACHE_GID ]]; then
export APACHE_RUN_GROUP=$APACHE_GID
APACHE_GID_TO_CREATE=$(echo $APACHE_GID | sed 's/#//')
[ $(getent group openconext) ] || groupadd -g $APACHE_GID_TO_CREATE openconext
[ $(getent passwd openconext) ] || useradd -M -u $APACHE_UID_TO_CREATE -g $APACHE_GID_TO_CREATE openconext
else
[ $(getent passwd openconext) ] || useradd -M -u $APACHE_UID_TO_CREATE openconext
fi
Expand All @@ -34,8 +38,8 @@ for dir in \
"$APACHE_RUN_DIR" \
"$APACHE_LOG_DIR"; do
if [[ -v APACHE_UID_TO_CREATE ]]; then
if [[ -v APACHE_GUID_TO_CREATE ]]; then
chown "$APACHE_UID_TO_CREATE:$APACHE_GUID_TO_CREATE" "$dir"
if [[ -v APACHE_GID_TO_CREATE ]]; then
chown "$APACHE_UID_TO_CREATE:$APACHE_GID_TO_CREATE" "$dir"
else
chown "$APACHE_UID_TO_CREATE" "$dir"
fi
Expand Down
20 changes: 12 additions & 8 deletions apache2/bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ if [[ -v APACHE_RUN_USER ]]; then
APACHE_UID=$APACHE_RUN_USER
fi
if [[ -v APACHE_RUN_GROUP ]]; then
APACHE_GUID=$APACHE_RUN_GROUP
APACHE_GID=$APACHE_RUN_GROUP
fi

if [[ ! -v APACHE_GID ]] && [[ -v APACHE_GUID ]]; then
APACHE_GID=$APACHE_GUID
fi

# Read the envars for Apache2
Expand All @@ -19,11 +23,11 @@ source /etc/apache2/envvars
if [[ -v APACHE_UID ]]; then
export APACHE_RUN_USER=$APACHE_UID
APACHE_UID_TO_CREATE=$(echo $APACHE_UID | sed 's/#//')
if [[ -v APACHE_GUID ]]; then
export APACHE_RUN_GROUP=$APACHE_GUID
APACHE_GUID_TO_CREATE=$(echo $APACHE_GUID | sed 's/#//')
[ $(getent group openconext) ] || groupadd -g $APACHE_GUID_TO_CREATE openconext
[ $(getent passwd openconext) ] || useradd -M -u $APACHE_UID_TO_CREATE -g $APACHE_GUID_TO_CREATE openconext
if [[ -v APACHE_GID ]]; then
export APACHE_RUN_GROUP=$APACHE_GID
APACHE_GID_TO_CREATE=$(echo $APACHE_GID | sed 's/#//')
[ $(getent group openconext) ] || groupadd -g $APACHE_GID_TO_CREATE openconext
[ $(getent passwd openconext) ] || useradd -M -u $APACHE_UID_TO_CREATE -g $APACHE_GID_TO_CREATE openconext
else
[ $(getent passwd openconext) ] || useradd -M -u $APACHE_UID_TO_CREATE openconext
fi
Expand All @@ -35,8 +39,8 @@ for dir in \
"$APACHE_LOG_DIR" \
; do \
if [[ -v APACHE_UID_TO_CREATE ]]; then
if [[ -v APACHE_GUID_TO_CREATE ]]; then
chown -R "$APACHE_UID_TO_CREATE:$APACHE_GUID_TO_CREATE" "$dir";
if [[ -v APACHE_GID_TO_CREATE ]]; then
chown -R "$APACHE_UID_TO_CREATE:$APACHE_GID_TO_CREATE" "$dir";
else
chown -R "$APACHE_UID_TO_CREATE" "$dir";
fi
Expand Down
18 changes: 11 additions & 7 deletions php72-apache2/bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ set +e
# Read the envars for Apache2
source /etc/apache2/envvars

if [[ ! -v APACHE_GID ]] && [[ -v APACHE_GUID ]]; then
APACHE_GID=$APACHE_GUID
fi

# Run as an arbitrary user / group if the user asked for one. It needs
# to be created first and stripped of the leading #
if [[ -v APACHE_UID ]]; then
export APACHE_RUN_USER=$APACHE_UID
APACHE_UID_TO_CREATE=$(echo $APACHE_UID | sed 's/#//')
if [[ -v APACHE_GUID ]]; then
export APACHE_RUN_GROUP=$APACHE_GUID
APACHE_GUID_TO_CREATE=$(echo $APACHE_GUID | sed 's/#//')
[ $(getent group openconext) ] || groupadd -g $APACHE_GUID_TO_CREATE openconext
[ $(getent passwd openconext) ] || useradd -M -u $APACHE_UID_TO_CREATE -g $APACHE_GUID_TO_CREATE openconext
if [[ -v APACHE_GID ]]; then
export APACHE_RUN_GROUP=$APACHE_GID
APACHE_GID_TO_CREATE=$(echo $APACHE_GID | sed 's/#//')
[ $(getent group openconext) ] || groupadd -g $APACHE_GID_TO_CREATE openconext
[ $(getent passwd openconext) ] || useradd -M -u $APACHE_UID_TO_CREATE -g $APACHE_GID_TO_CREATE openconext
else
[ $(getent passwd openconext) ] || useradd -M -u $APACHE_UID_TO_CREATE openconext
fi
Expand Down Expand Up @@ -41,8 +45,8 @@ fi

for dir in "${apache_dirs[@]}"; do
if [[ -v APACHE_UID_TO_CREATE ]]; then
if [[ -v APACHE_GUID_TO_CREATE ]]; then
chown -R "$APACHE_UID_TO_CREATE:$APACHE_GUID_TO_CREATE" "$dir"
if [[ -v APACHE_GID_TO_CREATE ]]; then
chown -R "$APACHE_UID_TO_CREATE:$APACHE_GID_TO_CREATE" "$dir"
else
chown -R "$APACHE_UID_TO_CREATE" "$dir"
fi
Expand Down
18 changes: 11 additions & 7 deletions php82-apache2/bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ set +e
# Read the envars for Apache2
source /etc/apache2/envvars

if [[ ! -v APACHE_GID ]] && [[ -v APACHE_GUID ]]; then
APACHE_GID=$APACHE_GUID
fi

# Run as an arbitrary user / group if the user asked for one. It needs
# to be created first and stripped of the leading #
if [[ -v APACHE_UID ]]; then
export APACHE_RUN_USER=$APACHE_UID
APACHE_UID_TO_CREATE=$(echo $APACHE_UID | sed 's/#//')
if [[ -v APACHE_GUID ]]; then
export APACHE_RUN_GROUP=$APACHE_GUID
APACHE_GUID_TO_CREATE=$(echo $APACHE_GUID | sed 's/#//')
[ $(getent group openconext) ] || groupadd -g $APACHE_GUID_TO_CREATE openconext
[ $(getent passwd openconext) ] || useradd -M -u $APACHE_UID_TO_CREATE -g $APACHE_GUID_TO_CREATE openconext
if [[ -v APACHE_GID ]]; then
export APACHE_RUN_GROUP=$APACHE_GID
APACHE_GID_TO_CREATE=$(echo $APACHE_GID | sed 's/#//')
[ $(getent group openconext) ] || groupadd -g $APACHE_GID_TO_CREATE openconext
[ $(getent passwd openconext) ] || useradd -M -u $APACHE_UID_TO_CREATE -g $APACHE_GID_TO_CREATE openconext
else
[ $(getent passwd openconext) ] || useradd -M -u $APACHE_UID_TO_CREATE openconext
fi
Expand All @@ -37,8 +41,8 @@ fi

for dir in "${apache_dirs[@]}"; do
if [[ -v APACHE_UID_TO_CREATE ]]; then
if [[ -v APACHE_GUID_TO_CREATE ]]; then
chown -R "$APACHE_UID_TO_CREATE:$APACHE_GUID_TO_CREATE" "$dir"
if [[ -v APACHE_GID_TO_CREATE ]]; then
chown -R "$APACHE_UID_TO_CREATE:$APACHE_GID_TO_CREATE" "$dir"
else
chown -R "$APACHE_UID_TO_CREATE" "$dir"
fi
Expand Down
18 changes: 11 additions & 7 deletions php85-apache2/bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ set +e
# Read the envars for Apache2
source /etc/apache2/envvars

if [[ ! -v APACHE_GID ]] && [[ -v APACHE_GUID ]]; then
APACHE_GID=$APACHE_GUID
fi

# Run as an arbitrary user / group if the user asked for one. It needs
# to be created first and stripped of the leading #
if [[ -v APACHE_UID ]]; then
export APACHE_RUN_USER=$APACHE_UID
APACHE_UID_TO_CREATE=$(echo $APACHE_UID | sed 's/#//')
if [[ -v APACHE_GUID ]]; then
export APACHE_RUN_GROUP=$APACHE_GUID
APACHE_GUID_TO_CREATE=$(echo $APACHE_GUID | sed 's/#//')
[ $(getent group openconext) ] || groupadd -g $APACHE_GUID_TO_CREATE openconext
[ $(getent passwd openconext) ] || useradd -M -u $APACHE_UID_TO_CREATE -g $APACHE_GUID_TO_CREATE openconext
if [[ -v APACHE_GID ]]; then
export APACHE_RUN_GROUP=$APACHE_GID
APACHE_GID_TO_CREATE=$(echo $APACHE_GID | sed 's/#//')
[ $(getent group openconext) ] || groupadd -g $APACHE_GID_TO_CREATE openconext
[ $(getent passwd openconext) ] || useradd -M -u $APACHE_UID_TO_CREATE -g $APACHE_GID_TO_CREATE openconext
else
[ $(getent passwd openconext) ] || useradd -M -u $APACHE_UID_TO_CREATE openconext
fi
Expand All @@ -37,8 +41,8 @@ fi

for dir in "${apache_dirs[@]}"; do
if [[ -v APACHE_UID_TO_CREATE ]]; then
if [[ -v APACHE_GUID_TO_CREATE ]]; then
chown -R "$APACHE_UID_TO_CREATE:$APACHE_GUID_TO_CREATE" "$dir"
if [[ -v APACHE_GID_TO_CREATE ]]; then
chown -R "$APACHE_UID_TO_CREATE:$APACHE_GID_TO_CREATE" "$dir"
else
chown -R "$APACHE_UID_TO_CREATE" "$dir"
fi
Expand Down