2015-08-18 17:46:18 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This is the entrypoint script for the dockerfile. Executed in the
|
|
|
|
# container at runtime.
|
|
|
|
|
|
|
|
if [[ $# == 0 ]]; then
|
2016-07-04 06:10:36 +02:00
|
|
|
# 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
|
2015-08-18 17:46:18 +02:00
|
|
|
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
|
2016-07-04 07:28:47 +02:00
|
|
|
useradd -o -m -g $BUILDER_GID -u $BUILDER_UID $BUILDER_USER 2> /dev/null
|
|
|
|
export HOME=/home/${BUILDER_USER}
|
|
|
|
cp /root/.bashrc $HOME
|
|
|
|
chown $BUILDER_UID:$BUILDER_GID $HOME/.bashrc
|
2015-08-18 17:46:18 +02:00
|
|
|
|
|
|
|
# Run the command as the specified user/group.
|
|
|
|
exec chpst -u :$BUILDER_UID:$BUILDER_GID "$@"
|
|
|
|
else
|
|
|
|
# Just run the command as root.
|
|
|
|
exec "$@"
|
|
|
|
fi
|