mirror of
https://github.com/bensuperpc/dockcross.git
synced 2024-11-10 05:07:26 +01:00
8923c6a3c7
While the use of sudo (made possible by 53cf084
) allows to install
additional packages, the warning copied below was still reported.
To avoid this warning and streamline the installation of new packages,
this commit (1) introduces the concept of "pre_exec" entrypoint hook
and (2) adds such a hook to change the ownership of python "bin" and
"site-packages" directories for the manylinux images.
Warning reported are similar to this one:
```
The directory '/home/jcfr/.cache/pip/http' or its parent directory is
not owned by the current user and the cache has been disabled. Please
check the permissions and owner of that directory. If executing pip
with sudo, you may want sudo's -H flag.
```
Note that the sudo "-H" flag suggested in the warning is not available
in centos.
45 lines
1.5 KiB
Bash
Executable File
45 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# This is the entrypoint script for the dockerfile. Executed in the
|
|
# container at runtime.
|
|
|
|
if [[ $# == 0 ]]; then
|
|
# Presumably the image has been run directly, so help the user get
|
|
# started by outputting the dockcross script
|
|
if [[ -n $DEFAULT_DOCKCROSS_IMAGE ]]; then
|
|
head -n 2 /dockcross/dockcross
|
|
echo "DEFAULT_DOCKCROSS_IMAGE=$DEFAULT_DOCKCROSS_IMAGE"
|
|
tail -n +4 /dockcross/dockcross
|
|
else
|
|
cat /dockcross/dockcross
|
|
fi
|
|
exit 0
|
|
fi
|
|
|
|
# If we are running docker natively, we want to create a user in the container
|
|
# with the same UID and GID as the user on the host machine, so that any files
|
|
# created are owned by that user. Without this they are all owned by root.
|
|
# If we are running from boot2docker, this is not necessary.
|
|
# The dockcross script sets the BUILDER_UID and BUILDER_GID vars.
|
|
if [[ -n $BUILDER_UID ]] && [[ -n $BUILDER_GID ]]; then
|
|
|
|
groupadd -o -g $BUILDER_GID $BUILDER_GROUP 2> /dev/null
|
|
useradd -o -m -g $BUILDER_GID -u $BUILDER_UID $BUILDER_USER 2> /dev/null
|
|
echo "$BUILDER_USER ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
|
export HOME=/home/${BUILDER_USER}
|
|
shopt -s dotglob
|
|
cp -r /root/* $HOME/
|
|
chown -R $BUILDER_UID:$BUILDER_GID $HOME/*
|
|
|
|
# Additional updates specific to the image
|
|
if [[ -e /dockcross/pre_exec.sh ]]; then
|
|
/dockcross/pre_exec.sh
|
|
fi
|
|
|
|
# Run the command as the specified user/group.
|
|
exec chpst -u :$BUILDER_UID:$BUILDER_GID "$@"
|
|
else
|
|
# Just run the command as root.
|
|
exec "$@"
|
|
fi
|