mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-10-15 23:00:50 +00:00
11
native/docker/crossbuild-uid/Dockerfile
Normal file
11
native/docker/crossbuild-uid/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
FROM multiarch/crossbuild
|
||||
RUN cd /tmp; \
|
||||
git clone https://github.com/ncopa/su-exec.git; \
|
||||
cd /tmp/su-exec; \
|
||||
make; \
|
||||
cp su-exec /usr/bin; \
|
||||
rm -Rf /tmp/su-exec
|
||||
ENTRYPOINT [ "/usr/bin/crossbuild-uid", "/usr/bin/crossbuild" ]
|
||||
CMD ["/bin/bash"]
|
||||
WORKDIR /workdir
|
||||
COPY crossbuild-uid /usr/bin/crossbuild-uid
|
31
native/docker/crossbuild-uid/crossbuild-uid
Executable file
31
native/docker/crossbuild-uid/crossbuild-uid
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This is the entrypoint script for the dockerfile. Executed in the
|
||||
# container at runtime.
|
||||
|
||||
export PATH_ORIGIN=$PATH
|
||||
export LD_LIBRARY_PATH_ORIGIN=$LD_LIBRARY_PATH
|
||||
|
||||
# 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
|
||||
export HOME=/home/${BUILDER_USER}
|
||||
shopt -s dotglob
|
||||
cp -r /root/* $HOME/
|
||||
chown -R $BUILDER_UID:$BUILDER_GID $HOME
|
||||
|
||||
# Enable passwordless sudo capabilities for the user
|
||||
chown root:$BUILDER_GID $(which su-exec)
|
||||
chmod +s $(which su-exec); sync
|
||||
|
||||
# Run the command as the specified user/group.
|
||||
exec su-exec $BUILDER_UID:$BUILDER_GID "$@"
|
||||
else
|
||||
# Just run the command as root.
|
||||
exec "$@"
|
||||
fi
|
Reference in New Issue
Block a user