mirror of
https://github.com/bensuperpc/dockcross.git
synced 2026-07-26 04:48:08 +02:00
f3fc294a08
The manylinux images can take over a minute to start on spinning disks (not SSDs) because pre_exec.sh is changing the ownership of all the python install directories to be writable by the BUILDER_UID. This is detailed further in #853. I changed the build steps for manylinux images to add a group called `builder`, then change the python directories to be owned by the `builder` group, and group writable. I then changed pre_exec.sh to add BUILDER_USER to the builder group prior to the gosu switch to become BUILDER_USER. The result is that BUILDER_USER is in the `builder` group that can write to the python directories, allowing the user to install python packages without permission denied errors. There was one additional change to support this, and that was the arguments to `gosu` in entrypoint.sh. Previously the arguments were `$BUILDER_UID:BUILDER_GID`, but providing the gid prevents `gosu` from loading additional groups (such as `builder`) from /etc/group. I removed the GID argument to allow `gosu` to pick up additional groups from /etc/group. fixes #853
61 lines
2.1 KiB
Bash
Executable File
61 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env 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.sh
|
|
echo "DEFAULT_DOCKCROSS_IMAGE=$DEFAULT_DOCKCROSS_IMAGE"
|
|
tail -n +4 /dockcross/dockcross.sh |
|
|
sed -e "s@dockcross\/linux\-armv7@${DEFAULT_DOCKCROSS_IMAGE}@g" |
|
|
sed -e "s@dockcross\-linux\-armv7@${DEFAULT_DOCKCROSS_IMAGE//[\/:]/-}@g"
|
|
else
|
|
cat /dockcross/dockcross.sh
|
|
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.
|
|
# 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
|
|
|
|
# Change ownership of /dev/pts/0 to new user
|
|
chown "$BUILDER_UID" /dev/pts/0 2> /dev/null
|
|
|
|
export HOME=/home/${BUILDER_USER}
|
|
shopt -s dotglob
|
|
# Copy the rest
|
|
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
|
|
|
|
# Enable passwordless sudo capabilities for the user
|
|
chown root:$BUILDER_GID "$(which gosu)"
|
|
chmod +s "$(which gosu)"
|
|
|
|
# Execute project specific pre execution hook
|
|
if [[ -e /work/.dockcross ]]; then
|
|
gosu $BUILDER_UID:$BUILDER_GID /work/.dockcross
|
|
fi
|
|
|
|
# Run the command as the specified user. The group will be BUILDER_GID,
|
|
# as pulled from /etc/passwd, but will have additional groups from
|
|
# /etc/group. This is necessary for manylinux to install python packages.
|
|
exec gosu $BUILDER_UID "$@"
|
|
else
|
|
# Just run the command as root.
|
|
exec "$@"
|
|
fi
|